I'm trying to do tic-tac-toe game using matrix, but the conditions for winning don't work. How do I fix it?
I have already tried If(){}else{}.
void win(int a[SIZE][SIZE], int* win){
if(a[0][0]==1 && a[0][1]==1 && a[0][2]==1){
*win=3;
}
if(a[0][0]==1 && a[1][0]==1 && a[2][0]==1){
*win=3;
}
if(a[0][1]==1 && a[1][1]==1 && a[2][1]==1){
*win=3;
}
if(a[0][2]==1 && a[1][2]==1 && a[2][2]==1){
*win=3;
}
}
It should enter the last two if, and put 3 inside of the pointer *win.
Aucun commentaire:
Enregistrer un commentaire