미완성. 일단 올려놓고 나중에 고칠게요.
#include<stdio.h>
#pragma warning(disable:4996)
int trans[5][5]={0, };
int num1=0, num2=0;
int main()
{
printf(" 1 2 3 4 5 \n");
printf(" ┌─┬─┬─┬─┬─┐\n");
printf("1│ │★│ │ │ │\n");
printf(" ├─┼─┼─┼─┼─┤\n");
printf("2│ │ │ │ │ │\n");
printf(" ├─┼─┼─┼─┼─┤\n");
printf("3│ │ │ │ │ │\n");
printf(" ├─┼─┼─┼─┼─┤\n");
printf("4│ │ │ │ │ │\n");
printf(" ├─┼─┼─┼─┼─┤\n");
printf("5│ │ │ │ │ │\n");
printf(" └─┴─┴─┴─┴─┘\n\n");
printf("표의 ★는 (1,2)좌표를 나타내는 것입니다.\n\n");
for(num1=0;num1<5;num1++)
{
for(num2=0;num2<5;num2++)
{
printf("(%d,%d)의 숫자를 입력하세요.\n", num1+1, num2+1);
scanf("%d", &trans[num1][num2]);
}
}
system("pause");
system("cls");
printf(" 1 2 3 4 5 \n");
printf(" ┌─┬─┬─┬─┬─┐\n1│");
for(num2=0;num2<5;num2++)
{
num1=0;
printf("%2d│", trans[num1][num2]);
}
for(num1=1;num1<5;num1++)
{
if(num2=4)
{
printf("\n ├─┼─┼─┼─┼─┤\n%d│", num1+1);
}
for(num2=0;num2<5;num2++)
{
printf("%2d│", trans[num1][num2]);
}
}
printf("\n └─┴─┴─┴─┴─┘\n\n");
printf(" ↓\n\n");
printf(" 1 2 3 4 5 \n");
printf(" ┌─┬─┬─┬─┬─┐\n1│");
for(num2=0;num2<5;num2++)
{
num1=0;
printf("%2d│", trans[num2][num1]);
}
for(num1=1;num1<5;num1++)
{
if(num2=4)
{
printf("\n ├─┼─┼─┼─┼─┤\n%d│", num1+1);
}
for(num2=0;num2<5;num2++)
{
printf("%2d│", trans[num2][num1]);
}
}
printf("\n └─┴─┴─┴─┴─┘\n\n\n");
system("pause");
return 0;
}
#include<stdio.h>
#pragma warning(disable:4996)
#include <windows.h>
char trans[3][3]={0, };
int num1=0, num2=0, com1=0, com2=0, times=0;
void gotoxy(int x, int y)
{
COORD Cur;
Cur.X=x;
Cur.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),Cur);
}
char ttt();
int main()
{
printf("Tic-Tac-Toe 게임\n\n");
printf(" 1 2 3 \n");
printf(" ┌─┬─┬─┐\n");
printf("1│ │★│ │\n");
printf(" ├─┼─┼─┤\n");
printf("2│ │ │ │\n");
printf(" ├─┼─┼─┤\n");
printf("3│ │ │ │\n");
printf(" └─┴─┴─┘\n");
printf("표의 ★는 (1,2)좌표를 나타내는 것입니다.\n\n");
system("pause");
system("cls");
printf(" 1 2 3 \n");
printf(" ┌─┬─┬─┐\n");
printf("1│%2c│%2c│%2c│\n", trans[0][0], trans[0][1], trans[0][2]);
printf(" ├─┼─┼─┤\n");
printf("2│%2c│%2c│%2c│\n", trans[1][0], trans[1][1], trans[1][2]);
printf(" ├─┼─┼─┤\n");
printf("3│%2c│%2c│%2c│\n", trans[2][0], trans[2][1], trans[2][2]);
printf(" └─┴─┴─┘\n\n");
printf("원하시는 좌표를 입력하세요. : ( , )");
gotoxy(31,9);
scanf("%d", &num1);
gotoxy(33,9);
scanf("%d", &num2);
while(times<9)
{
ttt();
}
system("pause");
}
char ttt()
{
trans[num2-1][num1-1]='O';
times++;
srand((unsigned)time(NULL));
com1=rand()%3;
com2=rand()%3;
if(trans[com2][com1]!='/0')
{
while(trans[com2][com1]=='/0')
{
com1=rand()%3;
com2=rand()%3;
}
trans[com2][com1]='X';
}
times++;
system("cls");
printf(" 1 2 3 \n");
printf(" ┌─┬─┬─┐\n");
printf("1│%2c│%2c│%2c│\n", trans[0][0], trans[0][1], trans[0][2]);
printf(" ├─┼─┼─┤\n");
printf("2│%2c│%2c│%2c│\n", trans[1][0], trans[1][1], trans[1][2]);
printf(" ├─┼─┼─┤\n");
printf("3│%2c│%2c│%2c│\n", trans[2][0], trans[2][1], trans[2][2]);
printf(" └─┴─┴─┘\n\n");
printf("원하시는 좌표를 입력하세요. : ( , )");
gotoxy(31,9);
scanf("%d", &num1);
gotoxy(33,9);
scanf("%d", &num2);
}