摘要
针对目前比较流行的"数独"游戏,利用C#提供的数据结构,设计了一种"测试-回溯"算法。该算法根据"数独"游戏的规则和约束条件计算并记录每个空白宫格内允许填写的数字,在此基础上试填每个空白宫格。当所有空白空格被填完后,可得到一个"数独"问题的解。
For solving the popular Sudoku game,an algorithm based on "check-backtracking"approach and C# is presented.First,this algorithm computes and saves the feasible digits for each blank grid based on the rules of Sudoku and the constraints generated by the existed digits in other grids.Second,fill the blank grid by choosing one feasible digit from a feasible digit list.When all blank grids are filled with proper digits,the game is over and a solution is achieved at last.
出处
《电脑编程技巧与维护》
2010年第14期24-25,共2页
Computer Programming Skills & Maintenance
关键词
数独游戏
算法
回溯
栈
C#
Sudoku Game
Algorithm
Backtracking
Stack
C#