diff --git a/TTT/bin/Debug/TTT.exe b/TTT/bin/Debug/TTT.exe index 4acf4dc..5319d99 100644 Binary files a/TTT/bin/Debug/TTT.exe and b/TTT/bin/Debug/TTT.exe differ diff --git a/TTT/functions.c b/TTT/functions.c index a6d5ebb..cfae8a9 100644 --- a/TTT/functions.c +++ b/TTT/functions.c @@ -31,13 +31,13 @@ void init_board(char arr[3][3]) // } } } -int whom_act() //选择谁先行动 +int who_act() //选择谁先行动 { - int input = 0; + int input = 0;char ch=0; printf("****************************\n"); printf("** Who goes first? **\n"); printf("** 1:Computer **\n"); - printf("** 0:You **\n"); + printf("** 2:You **\n"); printf("****************************\n"); while (1) { @@ -45,10 +45,13 @@ int whom_act() //选 scanf("%d", &input); if (input == 1) return 1; - else if (input == 0) - return 0; + else if (input == 2) + return 2; else + { + while ((ch = getchar()) != EOF && ch != '\n'); printf("wrong input\n"); + } } } int check_(char arr[3][3]) //判断棋子是否下满 @@ -82,9 +85,9 @@ void player_act(char arr[3][3]) // char ch; while (1) { - printf("Coordinnate:(x,y) 1<=x<=3,1<=y<=3\n"); - scanf("%d,%d", &x, &y); - if(arr[--x][--y] == ' ') + printf("Coordinnate: x,y (0 #include #define computer_first 1 -#define player_first 0 +#define player_first 2 #define start_game 1 #define end_game 0 #define full 9 @@ -17,7 +17,7 @@ void print_board(char arr[3][3]); //鎵撳嵃妫嬬洏 void menu(); //鑿滃崟 -int whom_act(); //閫夋嫨璋佸厛琛屽姩 +int who_act(); //閫夋嫨璋佸厛琛屽姩 int check_(char arr[3][3]); //鍒ゆ柇妫嬬洏鐘舵