/* ex1208.c */ #include <stdio.h> int main() { char tictactoe[3][3][3]; int x,y,z; /*initialize matrix*/ for(x=0;x<3;x++) for(y=0;y<3;y++) for(z=0;z<3;z++) tictactoe[x][y][z]='.'; tictactoe[1][1][1]='X'; /*display gameboard*/ puts("Ready to play Tic-Tac-Toe?"); for(z=0;z<3;z++) { printf("Level %d\n",z+1); for(x=0;x<3;x++) { for(y=0;y<3;y++) printf("%c ",tictactoe[x][y][z]); putchar('\n'); } } return(0); }
output:
Ready to play Tic-Tac-Toe? Level 1 . . . . . . . . . Level 2 . . . . X . . . . Level 3 . . . . . . . . . Process returned 0 (0x0) execution time : 0.079 s Press any key to continue.
Tidak ada komentar:
Posting Komentar