SEsource/三子棋/test.c

75 lines
1.4 KiB
C
Raw Normal View History

2023-08-07 11:00:03 +00:00
//test.c <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>߼<EFBFBD>
//game.h<><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>صĺ<D8B5><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD><C4BC>İ<EFBFBD><C4B0><EFBFBD>
//game.c <20><>Ϸ<EFBFBD><CFB7><EFBFBD>غ<EFBFBD><D8BA><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
#include "game.h"
void menu(){
printf("*************************\n");
printf("**** 1.play **********\n");
printf("**** 0.exit **********\n");
printf("*************************\n");
}
void game(){
//<2F><EFBFBD><E6B4A2><EFBFBD><EFBFBD>---<2D><>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
char board[ROW][COL];
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD> -- <20><>ʼ<EFBFBD><CABC><EFBFBD>ո<EFBFBD>
initBoard(board,ROW,COL);
//<2F><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
displayBoard(board,ROW,COL);
char ret = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ״̬
while(1){
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
playMove(board,ROW,COL);
displayBoard(board,ROW,COL);
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ӯ<EFBFBD><D3AE><EFBFBD><EFBFBD>Ϸ
ret = isWin(board,ROW,COL);
if(ret != 'C'){
break;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
computerMove(board,ROW,COL);
displayBoard(board,ROW,COL);
//<2F>жϵ<D0B6><CFB5><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ӯ<EFBFBD><D3AE><EFBFBD><EFBFBD>Ϸ
ret = isWin(board,ROW,COL);
if(ret != 'C'){
break;
}
}
if(ret == '*'){
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӯ<EFBFBD><EFBFBD>\n");
}else if(ret == '#'){
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӯ<EFBFBD><EFBFBD>\n");
}else{
printf("ƽ<EFBFBD><EFBFBD>\n");
}
displayBoard(board,ROW,COL);
}
int main(){
int input = 0;
srand((unsigned int)time(NULL));
do{
menu();
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>>");
scanf("%d",&input);
switch(input){
case 1:
game();
break;
case 0:
printf("<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><EFBFBD>\n");
break;
default:
printf("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
break;
}
}while(input);
return 0;
}