1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int main(void) { char board[3][3]; int x, y, k, i; // º¸µå¸¦ ÃʱâÈÇÑ´Ù. for (x = 0; x < 3; x++) for (y = 0; y < 3; y++) board[x][y] = ' '; // »ç¿ëÀڷκÎÅÍ À§Ä¡¸¦ ¹Þ¾Æ¼ º¸µå¿¡ Ç¥½ÃÇÑ´Ù. for (k = 0; k < 9; k++) { printf("(x, y) ÁÂÇ¥: "); scanf("%d %d", &x, &y); board[x][y] = (k % 2 == 0) ? 'X' : 'O'; // ÇöÀçÀÇ ¼ø¹ø¿¡ µû¶ó 'X', 'O'Áß ¼±Åà // º¸µå¸¦ ȸ鿡 ±×¸°´Ù. for (i = 0; i < 3; i++) { printf("---|---|---\n"); printf(" %c | %c | %c \n", board[i][0], board[i][1], board[i][2]); } printf("---|---|---\n"); } return 0; } | cs |