Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //fonction qui va permettre de compter le nombre de points gagnés par fruit/légume
- void verification(char tab[20][40], int *pointS,int *pointF,int *pointP,int *pointO,int *pointM){
- int i, j, k, l, n=0, cas=0;
- for(i=0;i<20;i++){
- for(j=0;j<40;j++){
- while(1){ //boucle infinie qui ne se termine qu'une fois les tests effectués
- //on commence par tester les 5== de suite en ligne et en colonne
- if((tab[i][j]==tab[i+1][j] && tab[i][j]==tab[i+2][j] && tab[i][j]==tab[i+3][j] && tab[i][j]==tab[i+4][j]) || (tab[i][j]==tab[i][j+1] && tab[i][j]==tab[i][j+2] && tab[i][j]==tab[i][j+3] && tab[i][j]==tab[i][j+4])){
- for (k=0;k<20;k++){
- for(l=0;l<40;l++){
- if(tab[k][l]==tab[i][j]) n++; //ici, on cherche toutes les cases du tableau de même lettre que les 5 identiques
- }
- }
- if(tab[i][j]=='S') pointS+=n;
- if(tab[i][j]=='F') pointF+=n;
- if(tab[i][j]=='P') pointP+=n;
- if(tab[i][j]=='O') pointO+=n;
- if(tab[i][j]=='M') pointM+=n;
- break; //bien noter la fonction break ici qui permet au while(1) de ne pas tourner à l'infini !
- } //puis les 4== en ligne
- if(tab[i][j]==tab[i+1][j] && tab[i][j]==tab[i+2][j] && tab[i][j]==tab[i+3][j]){
- cas=4;
- if(tab[i][j]=='S') pointS+=8;
- if(tab[i][j]=='F') pointF+=8;
- if(tab[i][j]=='P') pointP+=8;
- if(tab[i][j]=='O') pointO+=8;
- if(tab[i][j]=='M') pointM+=8;
- break;
- } //maintenant, les 4== en colonne
- if(tab[i][j]==tab[i][j+1] && tab[i][j]==tab[i][j+2] && tab[i][j]==tab[i][j+3]){
- cas=6;
- if(tab[i][j]=='S') pointS+=8;
- if(tab[i][j]=='F') pointF+=8;
- if(tab[i][j]=='P') pointP+=8;
- if(tab[i][j]=='O') pointO+=8;
- if(tab[i][j]=='M') pointM+=8;
- break;
- } //et enfin les 3== en ligne
- if(tab[i][j]==tab[i+1][j]==tab[i+2][j]){
- cas=3;
- if(tab[i][j]=='S') pointS+=3;
- if(tab[i][j]=='F') pointF+=3;
- if(tab[i][j]=='P') pointP+=3;
- if(tab[i][j]=='O') pointO+=3;
- if(tab[i][j]=='M') pointM+=3;
- break;
- } //au tour des 3== en colonne
- if(tab[i][j]==tab[i][j+1]==tab[i][j+2]){
- cas=5;
- if(tab[i][j]=='S') pointS+=3;
- if(tab[i][j]=='F') pointF+=3;
- if(tab[i][j]=='P') pointP+=3;
- if(tab[i][j]=='O') pointO+=3;
- if(tab[i][j]=='M') pointM+=3;
- break;
- }
- else break; //dans TOUS les cas, il y aura un break qui permettre de sortir du while(1)
- } //fin de la boucle infinie while(1). Maintenant, on doit tester les différentes formes spéciales possibles selon les cas précédents
- if (cas==4){ //test qui cherche les différentes formes possibles (croix, L...) --> ici, pour le cas où on a 4 lettres identiques en ligne
- if ((tab[i][j]==tab[i][j+1] && tab[i][j]==tab[i][j+2]) || (tab[i][j]==tab[i][j-1] && tab[i][j]==tab[i][j-2]) || (tab[i][j]==tab[i][j+1] && tab[i][j]==tab[i][j-1]) || (tab[i+1][j]==tab[i+1][j+1] && tab[i+1][j]==tab[i+1][j+2]) || (tab[i+1][j]==tab[i+1][j-1] && tab[i+1][j]==tab[i+1][j-2]) || (tab[i+1][j]==tab[i+1][j+1] && tab[i+1][j]==tab[i+1][j-1]) || (tab[i+2][j]==tab[i+2][j+1] && tab[i+2][j]==tab[i+2][j+2]) || (tab[i+2][j]==tab[i+2][j-1] && tab[i+2][j]==tab[i+2][j-2]) || (tab[i+2][j]==tab[i+2][j+1] && tab[i+2][j]==tab[i+2][j-1]) || (tab[i+3][j]==tab[i+3][j+1] && tab[i+3][j]==tab[i+3][j+2]) || (tab[i+3][j]==tab[i+3][j-1] && tab[i+3][j]==tab[i+3][j-2]) || (tab[i+3][j]==tab[i+3][j+1] && tab[i+3][j]==tab[i+3][j-1])){
- if(tab[i][j]=='S') pointS+=6;
- if(tab[i][j]=='F') pointF+=6;
- if(tab[i][j]=='P') pointP+=6;
- if(tab[i][j]=='O') pointO+=6;
- if(tab[i][j]=='M') pointM+=6;
- }
- }
- if (cas==3){ //pour le cas où il y a 3 lettres identiques horizontales
- if ((tab[i][j]==tab[i][j+1] && tab[i][j]==tab[i][j+2]) || (tab[i][j]==tab[i][j-1] && tab[i][j]==tab[i][j-2]) || (tab[i][j]==tab[i][j+1] && tab[i][j]==tab[i][j-1]) || (tab[i+1][j]==tab[i+1][j+1] && tab[i+1][j]==tab[i+1][j+2]) || (tab[i+1][j]==tab[i+1][j-1] && tab[i+1][j]==tab[i+1][j-2]) || (tab[i+1][j]==tab[i+1][j+1] && tab[i+1][j]==tab[i+1][j-1]) || (tab[i+2][j]==tab[i+2][j+1] && tab[i+2][j]==tab[i+2][j+2]) || (tab[i+2][j]==tab[i+2][j-1] && tab[i+2][j]==tab[i+2][j-2]) || (tab[i+2][j]==tab[i+2][j+1] && tab[i+2][j]==tab[i+2][j-1])){
- if(tab[i][j]=='S') pointS+=9;
- if(tab[i][j]=='F') pointF+=9;
- if(tab[i][j]=='P') pointP+=9;
- if(tab[i][j]=='O') pointO+=9;
- if(tab[i][j]=='M') pointM+=9;
- }
- }
- if (cas==6){ //on test ici les formes possibles pour le cas où on a 4 lettres identiques en colonne
- if ((tab[i][j]==tab[i+1][j] && tab[i][j]==tab[i+2][j]) || (tab[i][j]==tab[i-1][j] && tab[i][j]==tab[i-2][j]) || (tab[i][j]==tab[i+1][j] && tab[i][j]==tab[i-1][j]) || (tab[i][j+1]==tab[i+1][j+1] && tab[i][j+1]==tab[i+2][j+2]) || (tab[i][j+1]==tab[i-1][j+1] && tab[i][j+1]==tab[i-2][j+1]) || (tab[i][j+1]==tab[i+1][j+1] && tab[i][j+1]==tab[i-1][j+1]) || (tab[i][j+2]==tab[i+1][j+2] && tab[i][j+2]==tab[i+2][j+2]) || (tab[i][j+2]==tab[i-1][j+2] && tab[i][j+2]==tab[i-2][j+2]) || (tab[i][j+2]==tab[i+1][j+2] && tab[i][j+2]==tab[i-1][j+2]) || (tab[i][j+3]==tab[i+1][j+3] && tab[i][j+3]==tab[i+2][j+3]) || (tab[i][j+3]==tab[i-1][j+3] && tab[i][j+3]==tab[i-2][j+3]) || (tab[i][j+3]==tab[i+1][j+3] && tab[i][j+3]==tab[i-1][j+3])){
- if(tab[i][j]=='S') pointS+=6;
- if(tab[i][j]=='F') pointF+=6;
- if(tab[i][j]=='P') pointP+=6;
- if(tab[i][j]=='O') pointO+=6;
- if(tab[i][j]=='M') pointM+=6;
- }
- }
- if (cas==5){ //on test ici les formes possibles pour le cas où on a 3 lettres identiques verticalement
- if ((tab[i][j]==tab[i+1][j] && tab[i][j]==tab[i+2][j]) || (tab[i][j]==tab[i-1][j] && tab[i][j]==tab[i-2][j]) || (tab[i][j]==tab[i+1][j] && tab[i][j]==tab[i-1][j]) || (tab[i][j+1]==tab[i+1][j+1] && tab[i][j+1]==tab[i+2][j+2]) || (tab[i][j+1]==tab[i-1][j+1] && tab[i][j+1]==tab[i-2][j+1]) || (tab[i][j+1]==tab[i+1][j+1] && tab[i][j+1]==tab[i-1][j+1]) || (tab[i][j+2]==tab[i+1][j+2] && tab[i][j+2]==tab[i+2][j+2]) || (tab[i][j+2]==tab[i-1][j+2] && tab[i][j+2]==tab[i-2][j+2]) || (tab[i][j+2]==tab[i+1][j+2] && tab[i][j+2]==tab[i-1][j+2])){
- if(tab[i][j]=='S') pointS+=9;
- if(tab[i][j]=='F') pointF+=9;
- if(tab[i][j]=='P') pointP+=9;
- if(tab[i][j]=='O') pointO+=9;
- if(tab[i][j]=='M') pointM+=9;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement