求用C语言解一个简单sudoku数独的程序

来源:百度知道 编辑:UC知道 时间:2024/06/18 22:39:52
写一个sudukoGrid.c 要求使用sudukoGrid.h 里的提示
要和main.c一起编译 然后能够解九宫数独 不单单是行和列不重复 每个小的九宫格也不能出现重复 只能用1维数组 就是[81] 不能用二维,只要根据sudukoGrid.h里的提示写出那几个functions就可以了
这里附上#include sudukoGrid.h

// SudukoGrid.h
#define MIN_VALUE '1'
#define MAX_VALUE '9'
#define EMPTY_VALUE '.'
#define NUM_VALUES (MAX_VALUE-MIN_VALUE+1)
#define GRID_SIZE (NUM_VALUES*NUM_VALUES)
#define MAX_CELL (GRID_SIZE - 1)

typedef int cell;
typedef char value;
typedef value sudukoGrid[GRID_SIZE];

// given a grid, replaces all the cells in that grid with characters read from standard input.
// EMPTY_VALUE means blank cell, digits stand for themselves, all other characters ignored
void readGame (sudukoGrid game);

// displays a sudoko grid in a format which can be read back by readGame
void showGame (sudukoGrid game);

// sets the specified cell to the specified digit.
// assum

void readGame (sudukoGrid game) {
cell currentCell = 0;
int inChar = getchar();
while (inChar != EOF) {
if (
((inChar >= MIN_VALUE) && (inChar <= MAX_VALUE)) ||
(inChar == EMPTY_VALUE)
) {
assert (currentCell <= MAX_CELL);
game [currentCell] = inChar;
currentCell++;
}
inChar = getchar();
}
assert (currentCell == (MAX_CELL+1));
}
第一个readgame,谁会别的?