sudoku.c
changeset 27 81a574d60c15
parent 9 c3fecc82ade6
child 29 7abf6146898e
equal deleted inserted replaced
26:d227047a3e88 27:81a574d60c15
    39 
    39 
    40 /* the easiest way to get statistics */
    40 /* the easiest way to get statistics */
    41 static unsigned long iterations = 0;
    41 static unsigned long iterations = 0;
    42 
    42 
    43 typedef struct Field Field;
    43 typedef struct Field Field;
       
    44 
    44 typedef Field **Board;
    45 typedef Field **Board;
    45 
    46 
    46 /**
    47 /**
    47  * read nxn fields from commandline and store it in the Board variable
    48  * read nxn fields from commandline and store it in the Board variable
    48  */
    49  */
   127  * go recursive from k to DIM^2 and try to solve the puzzle
   128  * go recursive from k to DIM^2 and try to solve the puzzle
   128  */
   129  */
   129 int solveBoard (Board board, int k)
   130 int solveBoard (Board board, int k)
   130 {
   131 {
   131     u_int i;
   132     u_int i;
       
   133 
   132     int q;
   134     int q;
   133 
   135 
   134     if ((++iterations > MAX_ITERATIONS))
   136     if ((++iterations > MAX_ITERATIONS))
   135         return FALSE;
   137         return FALSE;
   136 
   138 
   179 }
   181 }
   180 
   182 
   181 int main (int argc, char **argv)
   183 int main (int argc, char **argv)
   182 {
   184 {
   183     Board b;
   185     Board b;
       
   186 
   184     int i;
   187     int i;
       
   188 
   185     int ret;
   189     int ret;
       
   190 
   186     int colored = 0;
   191     int colored = 0;
   187 
   192 
   188     while ((i = getopt (argc, argv, "ch")) != -1) {
   193     while ((i = getopt (argc, argv, "ch")) != -1) {
   189         switch (i) {
   194         switch (i) {
   190         case 'h':
   195         case 'h':