Im trying to make my programs control keys depending on the users choice for these 3 controls:
(a) (b) (c)
0 1 2 1 2 3 7 8 9
3 4 5 4 5 6 4 5 6
6 7 8 7 8 9 1 2 3
i managed to finish the first two but for my 3rd one (keyboard c) numbers dont seem to come up right they randomly appear instead, what am i dong wrong :(
heres my code:
int main(){
int r,c,ui,cntr;
char kb, aray[3][3]={{'.','.','.'},{'.','.','.'},{'.','.','.'}};
map(aray);
printf(" Which keyboard method would u prefer? \n");
scanf("%c", &kb);
for(cntr=0;cntr<9;cntr++){
printf("Please play ur next move! \n \n");
scanf("%i", &ui);
if(kb=='b'){
ui--;
}
if(kb=='c' && 0<ui &&ui<4){
ui+=5;
}
if(kb=='c' && 3<ui &&ui<7){
ui--;
}
if(kb=='c' && 6<ui &&ui<10){
ui-=7;
}
r=ui/3;
c=ui%3;
if(aray[r][c]=='X'){
printf("Error choose a different spot! \n");
cntr--;
}else{
aray[r][c]='X';
system("cls");
map(aray);
}
}
Aucun commentaire:
Enregistrer un commentaire