1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
int colorie_zone_rec(int ** mat,int i,int j,int cpt,int cl,Grille *grille){
int aux=mat[i][j];
if(((i || j ) <0 ) || ((i || j ) > (grille->nbcase) ) || (!mat[i][j]))
return 0;
else {
mat[i][j]=cl;
Grille_chg_case(grille,i,j,mat[i][j]);
if(aux==mat[i-1][j]){
cpt+=colorie_zone_rec(mat,i-1,j,cpt,cl,grille);
}
if(aux==mat[i+1][j]){
cpt+=colorie_zone_rec(mat,i+1,j,cpt,cl,grille);
}
if(aux==mat[i][j+1]){
cpt+=colorie_zone_rec(mat,i,i+1,cpt,cl,grille);
}
if(mat[i][j]==mat[i][j-1]){
cpt+=colorie_zone_rec(mat,i,j-1,cpt,cl,grille);
}
}
return cpt;
} |
Partager