Solveur de Sudoku

Solveur de Sudoku - C - Programmation

Marsh Posté le 30-05-2008 à 20:44:10    

Salut tout le monde,
j'ai essayé de développer un solveur pour Sudoku, en langage C, mais celui-ci me fait une boucle infinie et je ne comprends pas pourquoi :(

 
Code :
  1. void solveur(int grille[TAILLE_GRILLE][TAILLE_GRILLE], int grille_fixe[TAILLE_GRILLE][TAILLE_GRILLE])
  2. {
  3.     int i=0, j=0, chiffre=1, case_ok=0;
  4.     while(i<9)
  5.     {
  6.         while(j<9)
  7.         {
  8.             if(grille_fixe[i][j] != 0)
  9.             {
  10.                 while(!case_ok || chiffre < 10)
  11.                 {
  12.                     if(autoriser_chiffre(grille, i, j, chiffre))
  13.                     {
  14.                         grille[i][j] = chiffre;
  15.                         case_ok = 1;
  16.                         j++;
  17.                     }
  18.                     else
  19.                     {
  20.                         chiffre++;
  21.                     }
  22.                 }
  23.                 if(!case_ok)
  24.                 {
  25.                     if(j != 0)
  26.                     {
  27.                         j--;
  28.                     }
  29.                     else
  30.                     {
  31.                         i--;
  32.                         j=8;
  33.                     }
  34.                 }
  35.                 else
  36.                 {
  37.                     if(j != 9)
  38.                     {
  39.                         j++;
  40.                     }
  41.                     else
  42.                     {
  43.                         i++;
  44.                         j=0;
  45.                     }
  46.                 }
  47.             }
  48.             else
  49.             {
  50.                 if(j != 9)
  51.                 {
  52.                     j++;
  53.                 }
  54.                 else
  55.                 {
  56.                     i++;
  57.                     j=0;
  58.                 }
  59.             }
  60.         }
  61.     }
  62. }
 

Merci :jap:


Message édité par koskoz le 30-05-2008 à 20:45:00

---------------
Twitter
Reply

Marsh Posté le 30-05-2008 à 20:44:10   

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed