Kamis, 11 Desember 2025

ex1206.c ready to play tictactoe?

/* ex1206.c */
#include <stdio.h>

int main()
{
    char tictactoe[3][3];
    int x,y;

    /* initialize matrix */
    for(x=0;x<3;x++)
        for(y=0;y<3;y++)
            tictactoe[x][y]='.';
    tictactoe[1][1]='X';

    /* display game board */
    puts("Ready to play Tic-Tac-Toe?");
    for(x=0;x<3;x++)
    {
        for(y=0;y<3;y++)
            printf("%c",tictactoe[x][y]);
        putchar('\n');
    }
    return(0);
}

output:
 
Ready to play Tic-Tac-Toe?
...
.X.
...

Process returned 0 (0x0)   execution time : 0.116 s
Press any key to continue.

Tidak ada komentar:

Posting Komentar