---
# System prepended metadata

title: CRO - TD2 - Sudoku
tags: [CRO, TD2, S2]

---

# CRO - TD2 - Sudoku

###### tags: `CRO` `S2` `TD2`

Proposition d'architecture d'implémentation :    
Region valide




```c
#define inf(i) i-i%3
#define sup(i) i-i%3+3
int sudokuValide(int sudoku[9][9])
{int i,j,k,ii,jj;

 for (i=0; i<9; i++) 
   for (j=0; j<9; j++) 
     {
       if ((sudoku[i][j]<0)||(sudoku[i][j]>9))
     fprintf(stdout,"coefficient (%d,%d) non valide (%d)\n",i,j,sudoku[i][j]);
       /* ligne */
       if (sudoku[i][j]!=0)
     {
       for (k=0; k<9; k++)
         if (k!=j)
           if (sudoku[i][j]==sudoku[i][k])
         {
           fprintf(stdout,"coefficient (%d,%d) identique à (%d,%d)\n",i,j,i,k);
           return(0);
         }
       /* ligne */
       for (k=0; k<9; k++)
         if (k!=i)
           if (sudoku[i][j]==sudoku[k][j])
         {
           fprintf(stdout,"coefficient (%d,%d) identique à (%d,%d)\n",i,j,k,j);
           return(0);
         }
       for (ii=inf(i); ii<sup(i); ii++)
         for (jj=inf(j); jj<sup(j); jj++)
           if ((ii!=i)&&(jj!=j))
         if (sudoku[i][j]==sudoku[ii][jj])
           {
             fprintf(stdout,"coefficient (%d,%d) identique à (%d,%d)\n",i,j,ii,jj);
             return(0);
           }
     }
     }
 return(1);
}
```