【发布时间】:2020-10-28 11:39:18
【问题描述】:
使用 Microsoft Visual Studio 2019 创建新的 C++ 控制台应用程序。 添加一个文件,将其命名为 tictactoe.c。 粘贴下面给出的代码 -
#include <stdio.h>
int main(void)
{
int player = 0;
int winner = 0;
char board[3][3] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'} };
//The main game loop. The game continues for up to 9 turns.
for (unsigned i = 0; i < 9 && winner == 0; ++i) {
//Display the board
printf("\n");
printf(" %c | %c | %c \n", board[0][0], board[0][1], board[0][2]);
printf("-----+-----+-----\n");
printf(" %c | %c | %c\n", board[1][0], board[1][1], board[1][2]);
printf("-----+-----+-----\n");
printf(" %c | %c | %c\n", board[2][0], board[2][1], board[2][2]);
player = i % 2 + 1;
}
return 0;
}
【问题讨论】:
标签: c++ c visual-studio-2019