arrays - C++ Sudoku Solver -
Help find out what's wrong with
readPuzzle
and printPuzzle
Requires works. SetOfSmallInts
is a set containing {1,2,3,4,5,6,7,8,9}
or any combination of those numbers singletonets (S)
Store a single number in a set. No matter what input I run on this program, I only use 1 I even if all input '-' output is 81 1. Any suggestions? To create an array of puzzle types in the main SetofSmallInts [9] [9]
.
// ====================================== ======================== / readPuzzle // ===================== STANDARD From the puzzle in ========================================= input // ================================================ ============== To read Zero (puzzle p) {int i, j; SetOfSmallInts s; S = boundary (1, 9); Four n; For (i = 0; i <+ 9; i ++) {for (j = 0; j & lt; 9; j ++) {n = scanf ("% c", and amp; n); If (n == '-') {p [i] [j] = s; } And if (n == 1 || n == 2 || n == 3 || n = 4 4 || n == 5 || n = 6 6 || n == 7 || n == 8 || N == 9) {P [I] [J] = Singletonet (N); }}}} // ============================================ ================== // printPuzzle // =========================== In Puzzle P =================================== PRINT // ========= ================================================= === Zero printpang (puzzle p) {int i, js, s; SetOfSmallInts x; For (i = 0; i <+ 9; i ++) {for (j = 0; j & lt; 9; j ++) {x = p [i] [j]; If (act (x)) {printf ("% i", 0); } And if (haslinglington (x)) // returns true, if x is set to singleton then {s = small (x); // SS printf ("% i", S) gives the smallest member; } Other {printf ("% c", '-'); }}}} // ============================================ ================= SHOPPAL // =========================== == ========================================= Displays in a format in the puzzle that is debugging Can be used for // ========================================= ================================================= ================================================= ===== ============================================= Main int (int argc, four ** argv) {puzzle p; ReadPuzzle (P); PrintPuzzle (P); Return 0; }
All you need is a scanf ("% c", & Amp; n)
is also a character
such as
else if (n == 1 || n == 2 || n == 3 || n == 4 || n == 5 || n == 6 || n == 7 || n == 8 || n = 9 9)
to n == '1'
etc etc
or else if (n> gt; = '1' & amp; amp; ; & Amp; N & lt; = '9')
Then you may
p [i] [j] = singleton set (n - '0') will be required;
Comments
Post a Comment