samedi 5 mai 2018

'if' use in a four-in-a-row game

So, I define the table, and then the game starts and it eventually goes here:

int k;
scanf(" %d", &k);
if (board[6][k] == '-' || ' '){
  board[6][k]='+';
 }

else if (board[5][k] == '-' || ' '){
board[5][k]='+';
   }


else if (board[4][k] == '-' || ' '){
board[4][k]='+';
   }

goes etc for 3,2,1,0 in the case of i. First time runs, I give k the value of 2 I get this - - + - - - - , which is what I want. Next round I give again the value of 2 expected to get a '+' above the first '+', however nothing is happening printing again the same table. Can you help me find the issue here?

Aucun commentaire:

Enregistrer un commentaire