From d17a1bd603bab1f30ade943db414c5a6983648e3 Mon Sep 17 00:00:00 2001 From: "18408000320@stu.hut.edu.cn" <18408000320@stu.hut.edu.cn> Date: Fri, 11 Jan 2019 14:36:19 +0800 Subject: [PATCH 1/4] first commit --- 文件2.c | 460 +++++++++++++++++++++++++++++++++++++++++++++++++++ 计分板2.c | 35 ++++ 2 files changed, 495 insertions(+) create mode 100644 文件2.c create mode 100644 计分板2.c diff --git a/文件2.c b/文件2.c new file mode 100644 index 0000000..0b3e4ba --- /dev/null +++ b/文件2.c @@ -0,0 +1,460 @@ +#include +#include +#include +#include"Ʒְ.c" +extern void jifenban();//һļļƷְ庯 +void huanying();//ӭ +void printqipan();//ӡ +void initqipan();//ʼ +void white();//׷ +void black();//ڷ +void startgame();//Ϸʼ +int panduan(int,int);//жӮ +int win(); //ʾ˭Ӯ +char p[19][19][4];// +int a,b,c,d,x,y,w,z,B,H;//BH¼׺ֵӮּƷ +char ch; +int whowin; +int last;//ʣλ + + +int main(){ + huanying(); + return 0; +} + +void startgame() //Ϸ庯 +{ + initqipan(); /*̳ʼ*/ + while(1) + { + black();//ڷ庯 + last--;//ʣλ + if(win()==1)//жǷһӮ + break; + system("cls");//Ļ + // + white();//׷庯 + last--;//ʣλ + if(win()==1)//жǷһӮ + break; + system("cls");//Ļ + if(last==0) + win();//ƽֽʤʾ˭Ӯ + } + printf(" Ƿ¿ʼϷ룺Y or N ");//ѯûǷһ + scanf("%s",&ch); + if(ch=='Y')//һ + { + system("cls"); + startgame();//ٴνϷʼϷ + } + if(ch=='N')//˳Ϸ + { + system("cls"); + printf(" ~Ϸ~");//Ϸ + jifenban();////////һļļƷְ庯///////// + } +} + + + void black() // +{ + printqipan(); + printf("\n ڷ \n");//ڷ + printf(" ʾΪ ո ꡱ2 3ʾΪ2Ϊ3 \n");//ʾûʽ + printf(" "); + scanf("%d%d",&x,&y); + while(1) + { + if(strcmp(p[x][y]," ")==0)//жλǷ + { + strcpy(p[x][y],"");//ûº + break; + } + else + printf(" ڴλӣ꣺");//ʾû + scanf("%d%d",&x,&y); + } + system("cls"); + printqipan(); + printf(" Ҫ룺Y N ");//ѯûǷҪ + scanf("%s",&ch); + if(ch=='Y') + { + system("cls"); + strcpy(p[x][y]," ");//ԭһ + black();//庯 + } + if(ch=='N') + return;//˳ + } + +void white() // +{ + printqipan();//ӡ̺ + printf("\n ׷ \n");//׷ + printf(" ʾΪ ո ꡱ2 3ʾΪ2Ϊ3 \n");//ʾʽ + printf(" "); + scanf("%d%d",&x,&y); + while(1) + { + if(strcmp(p[x][y]," ")==0)//жϴλǷ + { + strcpy(p[x][y],"");//û° + break; + } + else + printf(" ڴλӣ꣺");//ʾ + scanf("%d%d",&x,&y); + } + system("cls"); + printqipan(); + printf(" Ҫ룺Y N ");//ѯǷ + scanf("%s",&ch); + if(ch=='Y') + { + strcpy(p[x][y]," ");//ԭ + system("cls"); + white();// + } + if(ch=='N')//˳ + return; + } + + + int win() ///////ʾһӮ +{ + int havewinner=0; + int whowin; + whowin=panduan(x,y); //////ʾ˭Ӯ ׷ 1 ڷ 2 + if(whowin==1) + { + havewinner=1; + + printf(" \n ׷ʤ\n"); + B++;//ƷӮһ + + } + if(whowin==2) + { + havewinner=1; + + printf(" \n ڷʤ\n"); + H++;//ƷӮһ + + } + if(last==0&&havewinner==0) + printf("~ƽ~");//ƽʾ + return havewinner; +} + + + int panduan(int x,int y)/////////////жϺ +{ + char color[4];//巽ɫ + int count=1;//ͳƸ,Եͬһ + int i=1;//ˮƽֱ + int j=1;//iͬʱб + int winner=0;//1׷2ڷ + strcpy(color,p[x][y]); + //ˮƽ + while(strcmp(color,p[x][y-i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1;count=1; + while(strcmp(color,p[x][y-i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x][y-i],"Ӯ"); + i++;count++; + } + i=1; + while(strcmp(color,p[x][y+i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x][y+i],"Ӯ"); + i++;count++; + } + } + } + //ˮƽұ + i=1; + while(strcmp(color,p[x][y+i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1;count=1; + while(strcmp(color,p[x][y+i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x][y+i],"Ӯ"); + i++;count++; + } + i=1; + while(strcmp(color,p[x][y-i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x][y-i],"Ӯ"); + i++;count++; + } + } + } + + //ֱķ + //ֱϷ + i=1; + count=1;//֮ǰ + while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1; + while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x-i][y],"Ӯ"); + i++;count++; + } + i=1; + while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x+i][y],"Ӯ"); + i++;count++; + } + } + } + //ֱ· + i=1; + while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1; + while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x+i][y],"Ӯ"); + i++;count++; + } + i=1; + while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x-i][y],"Ӯ"); + i++;count++; + } + } + } + //ϵб Ϸ + i=1; + j=1; + count=1; + while(strcmp(color,p[x-i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + j++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1;j=1;count=1; + while(strcmp(color,p[x-i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x-i][y-j],"Ӯ"); + i++;j++;count++; + } + i=1;j=1; + while(strcmp(color,p[x+i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x+i][y+j],"Ӯ"); + i++;j++;count++; + } + } + } + //ϵб · + i=1; + j=1; + while(strcmp(color,p[x+i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + j++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1;j=1;count=1; + while(strcmp(color,p[x+i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x+i][y+j],"Ӯ"); + i++;j++;count++; + } + i=1;j=1; + while(strcmp(color,p[x-i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x-i][y-j],"Ӯ"); + i++;j++;count++; + } + } + } + //ϵб Ϸ + i=1; + j=1; + count=1; + while(strcmp(color,p[x-i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + j++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1;j=1;count=1; + while(strcmp(color,p[x-i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x-i][y+j],"Ӯ"); + i++;j++;count++; + } + i=1;j=1; + while(strcmp(color,p[x+i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x+i][y-j],"Ӯ"); + i++;j++;count++; + } + } + } + //ϵб · + i=1; + j=1; + while(strcmp(color,p[x+i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + i++; + j++; + count++; + if(count==5)//count5ж˭ӮˣȻʸû + { + if(strcmp(color,"")==0) + winner=1; + + else + winner=2; + strcpy(p[x][y],"Ӯ"); + i=1;j=1;count=1; + while(strcmp(color,p[x+i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x+i][y-j],"Ӯ"); + i++;j++;count++; + } + i=1;j=1; + while(strcmp(color,p[x-i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + { + strcpy(p[x-i][y+j],"Ӯ"); + i++;j++;count++; + } + } + } + return winner; +} + + + void initqipan() /////////ʼ +{ + int i,j; + for(i=0;i<19;i++) + for(j=0;j<19;j++) + strcpy(p[i][j]," "); +} + void printqipan() /*ӡ*/ +{ + int i,j; + system("color e2");//ĻΪɫΪɫ + printf(" ӭ\n"); + printf(" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 \n"); + printf(" \n"); + for(i=0,j=0;i<18;i++,j++){ + printf(" %2d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s%2d\n",j,p[i][0],p[i][1],p[i][2],p[i][3],p[i][4],p[i][5],p[i][6],p[i][7],p[i][8],p[i][9],p[i][10],p[i][11],p[i][12],p[i][13],p[i][14],p[i][15],p[i][16],p[i][17],p[i][18],j); + printf(" \n"); + } + printf(" 18 %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s18\n",p[18][0],p[18][1],p[18][2],p[18][3],p[18][4],p[18][5],p[18][6],p[18][7],p[18][8],p[18][9],p[18][10],p[18][11],p[18][12],p[18][13],p[18][14],p[18][15],p[18][16],p[18][17],p[18][18]); + printf(" \n"); + printf(" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 \n"); +} + + void huanying() //ӭ +{ + char choice; + int i,j; + system("color e2"); //ĻΪdzɫΪɫ + printf("\n\n\n\n\n\n\n\n\n\n\n"); + printf(" \n");/*ӭ*/ + for(i=0;i<5;i++) + printf(" \n"); + printf(" \n"); + for(i=0;i<3;i++) + printf(" \n"); + printf(" \n"); + printf(" \n\n"); + printf(" ӭϹҵѧϷ\n\n"); + printf(" ļ飺һϷ˭\n");/*Ϸ*/ + printf(" ͬɫӣ˭ӮñͰֱͺб45͡\n\n"); + printf(" *******************************СաСϳƷ***********************************\n"); + printf(" Ϫ ף \n"); + printf(" ׷ ɽ ȡ\n"); + printf(" Ͽ ˮ ᰡ\n"); + printf(" ǣб 󡣡\n"); + printf(" ʮ ֱ ָ б ǡ\n"); + printf(" ---ʫ͸\n\n");/*һ׹ʫ͸Ϸߡ*/ + printf(" һְɡ\n\n"); + printf(" ˶ս\n\n"); + printf(" 뿪ʼϷ1.ʼϷ 2.˳Ϸ ѡǣ");/*ûѡϷĿʼ˳Ϸ*/ + scanf("%s",&choice); + while(1){ + if(choice=='1'||choice=='2') + { + if(choice=='1') + { + system("cls"); + startgame(); ////////ʼϷ + } + if(choice=='2') + return ; + } + else + printf(" Ŷ");/*û淶ʾҪû*/ + scanf("%s",&choice); + } +} diff --git a/计分板2.c b/计分板2.c new file mode 100644 index 0000000..476f51d --- /dev/null +++ b/计分板2.c @@ -0,0 +1,35 @@ +#include +#include +extern void printqipan(); +void jifenban(){//Ƿְ + extern int B; + extern int H; + system("color e2"); + printf("\n\n"); + printqipan(); + printf("\n\n"); + printf(" _____________\n"); + printf(" +++++ \n"); + printf(" +++++ \n"); + printf(" _____________________ __________________________________\n"); + printf(" ( ) \n"); + printf(" / \\ ׷ѡֻʤ%2d \n",B); + printf(" / || || \\ _______________________________\n"); + printf(" { } \n"); + printf(" < {ѡ} > ڷѡֻʤ%2d \n",H); + printf(" \\ ___С___ / _______________________________\n"); + printf(" \\ !|||||! / Ƿְ \n"); + printf(" --------------------------- _______________________________\n"); + printf(" |||||||||||||||||||||||||| \n"); + printf(" |||||||||||||||||||||||||| \n"); + printf(" \n"); + printf(" ____________________________________ \n"); + printf(" / \n"); + printf(" _______________________________________\n"); + printf(" \n"); + printf(" \\ \n"); + printf(" \n"); + printf(" _____________ \n"); + printf(" !YOU LOVE LOVE YOU!"); + return; +} From 7dd7546a51536f135c14af05053d6611dda4b210 Mon Sep 17 00:00:00 2001 From: "18408000320@stu.hut.edu.cn" <18408000320@stu.hut.edu.cn> Date: Fri, 11 Jan 2019 14:58:42 +0800 Subject: [PATCH 2/4] xiugai commit --- 文件2.c => 文件(2)(1).c | 56 ++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 23 deletions(-) rename 文件2.c => 文件(2)(1).c (88%) diff --git a/文件2.c b/文件(2)(1).c similarity index 88% rename from 文件2.c rename to 文件(2)(1).c index 0b3e4ba..73edbeb 100644 --- a/文件2.c +++ b/文件(2)(1).c @@ -54,6 +54,8 @@ void startgame() // system("cls"); printf(" ~Ϸ~");//Ϸ jifenban();////////һļļƷְ庯///////// + return; + } } @@ -67,13 +69,17 @@ void startgame() // scanf("%d%d",&x,&y); while(1) { - if(strcmp(p[x][y]," ")==0)//жλǷ + if(x>=0&&x<=18&&y>=0&&y<=18) + { + if(strcmp(p[x][y]," ")==0)//жλǷ { strcpy(p[x][y],"");//ûº break; } else printf(" ڴλӣ꣺");//ʾû + } + else printf(" 곬̷Χ"); scanf("%d%d",&x,&y); } system("cls"); @@ -99,13 +105,17 @@ void white() // scanf("%d%d",&x,&y); while(1) { - if(strcmp(p[x][y]," ")==0)//жϴλǷ + if(x>=0&&x<=18&&y>=0&&y<=18) { - strcpy(p[x][y],"");//û° + if(strcmp(p[x][y]," ")==0)//жλǷ + { + strcpy(p[x][y],"");//ûº break; } else - printf(" ڴλӣ꣺");//ʾ + printf(" ڴλӣ꣺");//ʾû + } + else printf(" 곬̷Χ"); scanf("%d%d",&x,&y); } system("cls"); @@ -227,14 +237,14 @@ void white() // else winner=2; strcpy(p[x][y],"Ӯ"); - i=1; - while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + i=1;count=1; + while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) { strcpy(p[x-i][y],"Ӯ"); i++;count++; } i=1; - while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) { strcpy(p[x+i][y],"Ӯ"); i++;count++; @@ -254,14 +264,14 @@ void white() // else winner=2; strcpy(p[x][y],"Ӯ"); - i=1; - while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + i=1;count=1; + while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) { strcpy(p[x+i][y],"Ӯ"); i++;count++; } i=1; - while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) + while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) { strcpy(p[x-i][y],"Ӯ"); i++;count++; @@ -420,27 +430,27 @@ void white() // int i,j; system("color e2"); //ĻΪdzɫΪɫ printf("\n\n\n\n\n\n\n\n\n\n\n"); - printf(" \n");/*ӭ*/ + printf(" \n");/*ӭ*/ for(i=0;i<5;i++) - printf(" \n"); - printf(" \n"); + printf(" \n"); + printf(" \n"); for(i=0;i<3;i++) - printf(" \n"); - printf(" \n"); - printf(" \n\n"); - printf(" ӭϹҵѧϷ\n\n"); + printf(" \n"); + printf(" \n"); + printf(" \n\n"); + printf(" ӭϹҵѧϷ\n\n"); printf(" ļ飺һϷ˭\n");/*Ϸ*/ - printf(" ͬɫӣ˭ӮñͰֱͺб45͡\n\n"); + printf(" ͬɫӣ˭ӮñͰֱͺб45͡\n\n"); printf(" *******************************СաСϳƷ***********************************\n"); printf(" Ϫ ף \n"); printf(" ׷ ɽ ȡ\n"); printf(" Ͽ ˮ ᰡ\n"); printf(" ǣб 󡣡\n"); - printf(" ʮ ֱ ָ б ǡ\n"); - printf(" ---ʫ͸\n\n");/*һ׹ʫ͸Ϸߡ*/ - printf(" һְɡ\n\n"); - printf(" ˶ս\n\n"); - printf(" 뿪ʼϷ1.ʼϷ 2.˳Ϸ ѡǣ");/*ûѡϷĿʼ˳Ϸ*/ + printf(" ʮ ֱ ָ б ǡ\n\n"); + printf(" ---ʫ͸\n\n");/*һ׹ʫ͸Ϸߡ*/ + printf(" һְɡ\n\n"); + printf(" ˶ս\n\n"); + printf(" 뿪ʼϷ1.ʼϷ 2.˳Ϸ\n\n ѡǣ");/*ûѡϷĿʼ˳Ϸ*/ scanf("%s",&choice); while(1){ if(choice=='1'||choice=='2') From 0b6f10a060b37b718c1ecd1ceed3d9aa84555ee8 Mon Sep 17 00:00:00 2001 From: "18408000320@stu.hut.edu.cn" <18408000320@stu.hut.edu.cn> Date: Fri, 11 Jan 2019 15:07:43 +0800 Subject: [PATCH 3/4] xiugai commit --- 计分板.c | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 计分板.c diff --git a/计分板.c b/计分板.c deleted file mode 100644 index 476f51d..0000000 --- a/计分板.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -extern void printqipan(); -void jifenban(){//Ƿְ - extern int B; - extern int H; - system("color e2"); - printf("\n\n"); - printqipan(); - printf("\n\n"); - printf(" _____________\n"); - printf(" +++++ \n"); - printf(" +++++ \n"); - printf(" _____________________ __________________________________\n"); - printf(" ( ) \n"); - printf(" / \\ ׷ѡֻʤ%2d \n",B); - printf(" / || || \\ _______________________________\n"); - printf(" { } \n"); - printf(" < {ѡ} > ڷѡֻʤ%2d \n",H); - printf(" \\ ___С___ / _______________________________\n"); - printf(" \\ !|||||! / Ƿְ \n"); - printf(" --------------------------- _______________________________\n"); - printf(" |||||||||||||||||||||||||| \n"); - printf(" |||||||||||||||||||||||||| \n"); - printf(" \n"); - printf(" ____________________________________ \n"); - printf(" / \n"); - printf(" _______________________________________\n"); - printf(" \n"); - printf(" \\ \n"); - printf(" \n"); - printf(" _____________ \n"); - printf(" !YOU LOVE LOVE YOU!"); - return; -} From 3f4a0ef7cfa4cad23f4ab2d19ca7844295808c2c Mon Sep 17 00:00:00 2001 From: "18408000320@stu.hut.edu.cn" <18408000320@stu.hut.edu.cn> Date: Fri, 11 Jan 2019 15:10:39 +0800 Subject: [PATCH 4/4] xiugai 2 --- 文件(1).c | 462 ---------------------------------------------------- 1 file changed, 462 deletions(-) delete mode 100644 文件(1).c diff --git a/文件(1).c b/文件(1).c deleted file mode 100644 index f46969a..0000000 --- a/文件(1).c +++ /dev/null @@ -1,462 +0,0 @@ -#include -#include -#include -#include"Ʒְ.c" -extern void jifenban();//һļļƷְ庯 -void huanying();//ӭ -void printqipan();//ӡ -void initqipan();//ʼ -void white();//׷ -void black();//ڷ -void startgame();//Ϸʼ -int panduan(int,int);//жӮ -int win(); //ʾ˭Ӯ -char p[19][19][4];// -int a,b,c,d,x,y,w,z,B,H;//BH¼׺ֵӮּƷ -char ch; -int whowin; -int last;//ʣλ - - -int main(){ - huanying(); - return 0; -} - -void startgame() //Ϸ庯 -{ - initqipan(); /*̳ʼ*/ - while(1) - { - black();//ڷ庯 - last--;//ʣλ - if(win()==1)//жǷһӮ - break; - system("cls");//Ļ - // - white();//׷庯 - last--;//ʣλ - if(win()==1)//жǷһӮ - break; - system("cls");//Ļ - if(last==0) - win();//ƽֽʤʾ˭Ӯ - } - printf(" Ƿ¿ʼϷ룺Y or N ");//ѯûǷһ - scanf("%s",&ch); - if(ch=='Y')//һ - { - system("cls"); - startgame();//ٴνϷʼϷ - } - if(ch=='N')//˳Ϸ - { - system("cls"); - printf(" ~Ϸ~");//Ϸ - jifenban();////////һļļƷְ庯///////// - return; - - } -} - - - void black() // -{ - printqipan(); - printf("\n ڷ \n");//ڷ - printf(" ʾΪ ո ꡱ2 3ʾΪ2Ϊ3 \n");//ʾûʽ - printf(" "); - scanf("%d%d",&x,&y); - while(1) - { - if(strcmp(p[x][y]," ")==0)//жλǷ - { - strcpy(p[x][y],"");//ûº - break; - } - else - printf(" ڴλӣ꣺");//ʾû - scanf("%d%d",&x,&y); - } - system("cls"); - printqipan(); - printf(" Ҫ룺Y N ");//ѯûǷҪ - scanf("%s",&ch); - if(ch=='Y') - { - system("cls"); - strcpy(p[x][y]," ");//ԭһ - black();//庯 - } - if(ch=='N') - return;//˳ - } - -void white() // -{ - printqipan();//ӡ̺ - printf("\n ׷ \n");//׷ - printf(" ʾΪ ո ꡱ2 3ʾΪ2Ϊ3 \n");//ʾʽ - printf(" "); - scanf("%d%d",&x,&y); - while(1) - { - if(strcmp(p[x][y]," ")==0)//жϴλǷ - { - strcpy(p[x][y],"");//û° - break; - } - else - printf(" ڴλӣ꣺");//ʾ - scanf("%d%d",&x,&y); - } - system("cls"); - printqipan(); - printf(" Ҫ룺Y N ");//ѯǷ - scanf("%s",&ch); - if(ch=='Y') - { - strcpy(p[x][y]," ");//ԭ - system("cls"); - white();// - } - if(ch=='N')//˳ - return; - } - - - int win() ///////ʾһӮ -{ - int havewinner=0; - int whowin; - whowin=panduan(x,y); //////ʾ˭Ӯ ׷ 1 ڷ 2 - if(whowin==1) - { - havewinner=1; - - printf(" \n ׷ʤ\n"); - B++;//ƷӮһ - - } - if(whowin==2) - { - havewinner=1; - - printf(" \n ڷʤ\n"); - H++;//ƷӮһ - - } - if(last==0&&havewinner==0) - printf("~ƽ~");//ƽʾ - return havewinner; -} - - - int panduan(int x,int y)/////////////жϺ -{ - char color[4];//巽ɫ - int count=1;//ͳƸ,Եͬһ - int i=1;//ˮƽֱ - int j=1;//iͬʱб - int winner=0;//1׷2ڷ - strcpy(color,p[x][y]); - //ˮƽ - while(strcmp(color,p[x][y-i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;count=1; - while(strcmp(color,p[x][y-i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x][y-i],"Ӯ"); - i++;count++; - } - i=1; - while(strcmp(color,p[x][y+i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x][y+i],"Ӯ"); - i++;count++; - } - } - } - //ˮƽұ - i=1; - while(strcmp(color,p[x][y+i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;count=1; - while(strcmp(color,p[x][y+i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x][y+i],"Ӯ"); - i++;count++; - } - i=1; - while(strcmp(color,p[x][y-i])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x][y-i],"Ӯ"); - i++;count++; - } - } - } - - //ֱķ - //ֱϷ - i=1; - count=1;//֮ǰ - while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;count=1; - while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) - { - strcpy(p[x-i][y],"Ӯ"); - i++;count++; - } - i=1; - while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) - { - strcpy(p[x+i][y],"Ӯ"); - i++;count++; - } - } - } - //ֱ· - i=1; - while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;count=1; - while(strcmp(color,p[x+i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) - { - strcpy(p[x+i][y],"Ӯ"); - i++;count++; - } - i=1; - while(strcmp(color,p[x-i][y])==0&&x>=0&&x<19&&y>=0&&y<19&&count<=5) - { - strcpy(p[x-i][y],"Ӯ"); - i++;count++; - } - } - } - //ϵб Ϸ - i=1; - j=1; - count=1; - while(strcmp(color,p[x-i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - j++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;j=1;count=1; - while(strcmp(color,p[x-i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x-i][y-j],"Ӯ"); - i++;j++;count++; - } - i=1;j=1; - while(strcmp(color,p[x+i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x+i][y+j],"Ӯ"); - i++;j++;count++; - } - } - } - //ϵб · - i=1; - j=1; - while(strcmp(color,p[x+i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - j++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;j=1;count=1; - while(strcmp(color,p[x+i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x+i][y+j],"Ӯ"); - i++;j++;count++; - } - i=1;j=1; - while(strcmp(color,p[x-i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x-i][y-j],"Ӯ"); - i++;j++;count++; - } - } - } - //ϵб Ϸ - i=1; - j=1; - count=1; - while(strcmp(color,p[x-i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - j++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;j=1;count=1; - while(strcmp(color,p[x-i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x-i][y+j],"Ӯ"); - i++;j++;count++; - } - i=1;j=1; - while(strcmp(color,p[x+i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x+i][y-j],"Ӯ"); - i++;j++;count++; - } - } - } - //ϵб · - i=1; - j=1; - while(strcmp(color,p[x+i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - i++; - j++; - count++; - if(count==5)//count5ж˭ӮˣȻʸû - { - if(strcmp(color,"")==0) - winner=1; - - else - winner=2; - strcpy(p[x][y],"Ӯ"); - i=1;j=1;count=1; - while(strcmp(color,p[x+i][y-j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x+i][y-j],"Ӯ"); - i++;j++;count++; - } - i=1;j=1; - while(strcmp(color,p[x-i][y+j])==0&&x>=0&&x<19&&y>=0&&y<19&&count<5) - { - strcpy(p[x-i][y+j],"Ӯ"); - i++;j++;count++; - } - } - } - return winner; -} - - - void initqipan() /////////ʼ -{ - int i,j; - for(i=0;i<19;i++) - for(j=0;j<19;j++) - strcpy(p[i][j]," "); -} - void printqipan() /*ӡ*/ -{ - int i,j; - system("color e2");//ĻΪɫΪɫ - printf(" ӭ\n"); - printf(" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 \n"); - printf(" \n"); - for(i=0,j=0;i<18;i++,j++){ - printf(" %2d %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s%2d\n",j,p[i][0],p[i][1],p[i][2],p[i][3],p[i][4],p[i][5],p[i][6],p[i][7],p[i][8],p[i][9],p[i][10],p[i][11],p[i][12],p[i][13],p[i][14],p[i][15],p[i][16],p[i][17],p[i][18],j); - printf(" \n"); - } - printf(" 18 %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s18\n",p[18][0],p[18][1],p[18][2],p[18][3],p[18][4],p[18][5],p[18][6],p[18][7],p[18][8],p[18][9],p[18][10],p[18][11],p[18][12],p[18][13],p[18][14],p[18][15],p[18][16],p[18][17],p[18][18]); - printf(" \n"); - printf(" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 \n"); -} - - void huanying() //ӭ -{ - char choice; - int i,j; - system("color e2"); //ĻΪdzɫΪɫ - printf("\n\n\n\n\n\n\n\n\n\n\n"); - printf(" \n");/*ӭ*/ - for(i=0;i<5;i++) - printf(" \n"); - printf(" \n"); - for(i=0;i<3;i++) - printf(" \n"); - printf(" \n"); - printf(" \n\n"); - printf(" ӭϹҵѧϷ\n\n"); - printf(" ļ飺һϷ˭\n");/*Ϸ*/ - printf(" ͬɫӣ˭ӮñͰֱͺб45͡\n\n"); - printf(" *******************************СաСϳƷ***********************************\n"); - printf(" Ϫ ף \n"); - printf(" ׷ ɽ ȡ\n"); - printf(" Ͽ ˮ ᰡ\n"); - printf(" ǣб 󡣡\n"); - printf(" ʮ ֱ ָ б ǡ\n\n"); - printf(" ---ʫ͸\n\n");/*һ׹ʫ͸Ϸߡ*/ - printf(" һְɡ\n\n"); - printf(" ˶ս\n\n"); - printf(" 뿪ʼϷ1.ʼϷ 2.˳Ϸ\n\n ѡǣ");/*ûѡϷĿʼ˳Ϸ*/ - scanf("%s",&choice); - while(1){ - if(choice=='1'||choice=='2') - { - if(choice=='1') - { - system("cls"); - startgame(); ////////ʼϷ - } - if(choice=='2') - return ; - } - else - printf(" Ŷ");/*û淶ʾҪû*/ - scanf("%s",&choice); - } -}