/* check.c - checks (parts of) Sudoku puzzle for legality YOUR NAME(S), DATE */ #include /* constants to return from your check functions */ #define PERFECT 2 #define OKAY 1 #define ILLEGAL 0 #define UNDONE -1 /* REQUIRED: COMPLETE okRow TO RETURN EITHER OKAY OR ILLEGAL. OPTIONAL: OR RETURN PERFECT IF THE ROW IS PERFECT. */ int okRow(int row[]) { return UNDONE; } /* OPTIONAL: SAME AS ABOVE BUT FOR COLUMN k OF puzzle. */ int okColumn(int puzzle[9][9], int k) { return UNDONE; } /* DO NOT CHANGE ANYTHING BELOW */ int main(void) { int puzzle[9][9], i, j; char *result[] = {"illegal", "okay", "perfect"}; /* fill array with data from user */ printf("enter 81 puzzle values in row order:\n"); for (i=0; i<9; i++) for (j=0; j<9; j++) if (scanf("%i", &puzzle[i][j]) < 1) { fprintf(stderr, "bad or incomplete data\n"); return 1; } /* print checks of all rows if okayRow function done */ for (i=0; i<9; i++) { int r = okRow(puzzle[i]); if (r >= 0 && r <= 2) printf("row %d is %s\n", i, result[r]); } /* print checks of all columns if okayColumn done */ for (i=0; i<9; i++) { int r = okColumn(puzzle, i); if (r >= 0 && r <= 2) printf("column %d is %s\n", i, result[r]); } return 0; }