#include <stdio.h>
#include<stdlib.h>
void banben(); //初始界面
void guize(); //界面规则
void printQP(); // 棋盘输出
int pd(int x,int y,int cc); //判断输赢
int hefa(int x,int y); //判断输入是否合法
char caidan(); //菜单选择
int a[16][16]={
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};
int main()
{
system("color 4e");
char m;
banben();
kaishi0:
fflush(stdin);//用于清理缓存
m=caidan();
while(1)
{
if(m=='a')//开始游戏
{
system("cls");
char e[7],f[7];
printf("请输入玩家一姓名(黑棋)支持中文:");
scanf("%s",e);
printf("请输入玩家二姓名(白棋)支持中文:");
scanf("%s",f);
printQP();
int x,y,cc,l=0,g=0;
while(g==0)
{
kaishi:
cc=1;
printf("%s下\n",e);
printf("如果要查看规则并返回请输入横坐标:44 纵坐标:44\n");
printf("请输入所要下棋子的横坐标:");
scanf("%d",&x);
printf("\n");
printf("请输入所要下棋子的纵坐标:");
scanf("%d",&y);
printf("\n");
if(x==44&&y==44)
{
system("cls");
goto kaishi0;
}
l=hefa(x,y);
if (l==1)
a[x][y]=1;
else
{
printf("棋子错误!\n");
goto kaishi;
}
if (a[x][y]==1)
{
system("cls");
printQP();
}
g=pd(x,y,cc);
if(g==1)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",e);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
if(g==2)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",f);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
/////////////////////////////////
kaishi2:
cc=2;
printf("%s下\n",f);
printf("如果要查看规则并返回请输入横坐标:44 纵坐标:44\n");
printf("请输入所要下棋子的横坐标:");
scanf("%d",&x);
printf("\n");
printf("请输入所要下棋子的纵坐标:");
scanf("%d",&y);
printf("\n");
if(x==44&&y==44)
{
system("cls");
goto kaishi0;
}
l=hefa(x,y);
if (l==1)
a[x][y]=2;
else
{
printf("棋子错误!\n");
goto kaishi2;
}
if (a[x][y]==2)
{
system("cls");
printQP();
}
g=0;
g=pd(x,y,cc);
if(g==1)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",e);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
if(g==2)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",f);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
}
}
if(m=='b')//重新开始
{
system("cls");
char e[7],f[7];
printf("请输入玩家一姓名(黑棋)支持中文:");
scanf("%s",e);
printf("请输入玩家二姓名(白棋)支持中文:");
scanf("%s",f);
printQP();
int x,y,cc,l=0,g=0;
while(g==0)
{
kaishi3:
cc=1;
printf("%s下\n",e);
printf("如果要查看规则并返回请输入横坐标:44 纵坐标:44\n");
printf("请输入所要下棋子的横坐标:");
scanf("%d",&x);
printf("\n");
printf("请输入所要下棋子的纵坐标:");
scanf("%d",&y);
printf("\n");
if(x==44&&y==44)
{
system("cls");
goto kaishi0;
}
l=hefa(x,y);
if (l==1)
a[x][y]=1;
else
{
printf("棋子错误!\n");
goto kaishi3;
}
if (a[x][y]==1)
{
system("cls");
printQP();
}
g=pd(x,y,cc);
if(g==1)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",e);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
if(g==2)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",f);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
/////////////////////////////////
kaishi4:
cc=2;
printf("%s下\n",f);
printf("如果要查看规则并返回请输入横坐标:44 纵坐标:44\n");
printf("请输入所要下棋子的横坐标:");
scanf("%d",&x);
printf("\n");
printf("请输入所要下棋子的纵坐标:");
scanf("%d",&y);
printf("\n");
if(x==44&&y==44)
{
system("cls");
goto kaishi0;
}
l=hefa(x,y);
if (l==1)
a[x][y]=2;
else
{
printf("棋子错误!\n");
goto kaishi4;
}
if (a[x][y]==2)
{
system("cls");
printQP();
}
g=0;
g=pd(x,y,cc);
if(g==1)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",e);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
if(g==2)
{
system("cls");
printf("%s赢,赞一个! ! ! ! !\n",f);
for(int i=1;i<16;i++)
for(int j=1;j<16;j++)
a[i][j]=0;
goto kaishi0;
}
}
}
if(m=='c')//查看规则
{ int x;
system("cls");
guize();
printf("\n\n");
printf("返回请输入:44\n");
scanf("%d",&x);
printf("\n");
if(x==44)
{
system("cls");
goto kaishi0;
}
}
if(m=='d')//退出游戏
{
system("cls");
printf("成功退出!!!!!\n");
return 0;
}
}
}
#include <stdio.h>
#include<stdlib.h>
void banben(); //初始界面
void guize(); //界面规则
void printQP(); // 棋盘输出
int pd(int x,int y,int cc); //判断输赢
int hefa(int x,int y); //判断输入是否合法
char caidan(); //菜单选择
int a[16][16]={
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
};
int main()
{
system("color 4e");
char m;
banben();