
#include "iostream"
#include <iomanip>
using namespace std;
#define M 20
#define N 20
int main()
{
char weizhi[M][N];
int k,i,j,x,y,flag=0;
cout < <"欢迎使用简易双人对战五子棋游戏" < <endl;
cout < <"五子棋棋谱如下:" < <endl;
for(k=0;k <=N;k++)
cout < <setw(3) < <setfill(' ') < <k;
cout < <endl;
for(i=1;i <=M;i++)
{
cout < <setw(3) < <setfill(' ') < <i;
for(j=1;j <=N;j++)
{
weizhi[i][j]='-';
cout < <setw(3) < <setfill(' ') < <weizhi[i][j];
}
cout < <endl;
}
while(flag==0)
{
//红方落子
cout < <"请红方输入落子位置:" < <endl;
loop1:
cout < <"请输入落子的行数:";
cin>>x;
cout < <"请输入落子的列数:";
cin>>y;
if(weizhi[x][y]=='-')
{
weizhi[x][y]='*';
for(k=0;k <=N;k++)
cout < <setw(3) < <setfill(' ') < <k;
cout < <endl;
for(i=1;i <=M;i++)
{
cout < <setw(3) < <setfill(' ') < <i;
for(j=1;j <=N;j++)
cout < <setw(3) < <setfill(' ') < <weizhi[i][j];
cout < <endl;
}
}
else
{
cout < <"你不能在这落子,请重新选择落子位置:" < <endl;
goto loop1;
}
//判断胜利
for(i=1;i <=M-4;i++)
{
for(j=1;j <=N-4;j++)
{
if(weizhi[i][j]=='*' && weizhi[i][j+1]=='*' && weizhi[i][j+2]=='*' && weizhi[i][j+3]=='*' && weizhi[i][j+4]=='*')
{
cout < <"恭喜红方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='*' && weizhi[i+1][j]=='*' && weizhi[i+2][j]=='*' && weizhi[i+3][j]=='*' && weizhi[i+4][j]=='*')
{
cout < <"恭喜红方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='*' && weizhi[i+1][j+1]=='*' && weizhi[i+2][j+2]=='*' && weizhi[i+3][j+3]=='*' && weizhi[i+4][j+4]=='*')
{
cout < <"恭喜红方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(flag==1)
break;
}
}
if(flag==1)
return 1;
//蓝方落子
cout < <"请蓝方输入落子位置:" < <endl;
loop2:
cout < <"请输入落子的行数:";
cin>>x;
cout < <"请输入落子的列数:";
cin>>y;
if(weizhi[x][y]=='-')
{
weizhi[x][y]='#';
for(k=0;k <=N;k++)
cout < <setw(3) < <setfill(' ') < <k;
cout < <endl;
for(i=1;i <=M;i++)
{
cout < <setw(3) < <setfill(' ') < <i;
for(j=1;j <=N;j++)
cout < <setw(3) < <setfill(' ') < <weizhi[i][j];
cout < <endl;
}
}
else
{
cout < <"你不能在这落子,请重新选择落子位置:";
goto loop2;
}
}
//判断胜利
for(i=1;i <=M-4;i++)
{
for(j=1;j <=N-4;j++)
{
if(weizhi[i][j]=='#' && weizhi[i][j+1]=='#' && weizhi[i][j+2]=='#' && weizhi[i][j+3]=='#' && weizhi[i][j+4]=='#')
{
cout < <"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='#' && weizhi[i+1][j]=='#' && weizhi[i+2][j]=='#' && weizhi[i+3][j]=='#' && weizhi[i+4][j]=='#')
{
cout < <"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='#' && weizhi[i+1][j+1]=='#' && weizhi[i+2][j+2]=='#' && weizhi[i+3][j+3]=='#' && weizhi[i+4][j+4]=='#')
{
cout < <"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(flag==1)
break;
}
}
return 0;
}
#include <iomanip>
using namespace std;
#define M 20
#define N 20
int main()
{
char weizhi[M][N];
int k,i,j,x,y,flag=0;
cout < <"欢迎使用简易双人对战五子棋游戏" < <endl;
cout < <"五子棋棋谱如下:" < <endl;
for(k=0;k <=N;k++)
cout < <setw(3) < <setfill(' ') < <k;
cout < <endl;
for(i=1;i <=M;i++)
{
cout < <setw(3) < <setfill(' ') < <i;
for(j=1;j <=N;j++)
{
weizhi[i][j]='-';
cout < <setw(3) < <setfill(' ') < <weizhi[i][j];
}
cout < <endl;
}
while(flag==0)
{
//红方落子
cout < <"请红方输入落子位置:" < <endl;
loop1:
cout < <"请输入落子的行数:";
cin>>x;
cout < <"请输入落子的列数:";
cin>>y;
if(weizhi[x][y]=='-')
{
weizhi[x][y]='*';
for(k=0;k <=N;k++)
cout < <setw(3) < <setfill(' ') < <k;
cout < <endl;
for(i=1;i <=M;i++)
{
cout < <setw(3) < <setfill(' ') < <i;
for(j=1;j <=N;j++)
cout < <setw(3) < <setfill(' ') < <weizhi[i][j];
cout < <endl;
}
}
else
{
cout < <"你不能在这落子,请重新选择落子位置:" < <endl;
goto loop1;
}
//判断胜利
for(i=1;i <=M-4;i++)
{
for(j=1;j <=N-4;j++)
{
if(weizhi[i][j]=='*' && weizhi[i][j+1]=='*' && weizhi[i][j+2]=='*' && weizhi[i][j+3]=='*' && weizhi[i][j+4]=='*')
{
cout < <"恭喜红方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='*' && weizhi[i+1][j]=='*' && weizhi[i+2][j]=='*' && weizhi[i+3][j]=='*' && weizhi[i+4][j]=='*')
{
cout < <"恭喜红方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='*' && weizhi[i+1][j+1]=='*' && weizhi[i+2][j+2]=='*' && weizhi[i+3][j+3]=='*' && weizhi[i+4][j+4]=='*')
{
cout < <"恭喜红方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(flag==1)
break;
}
}
if(flag==1)
return 1;
//蓝方落子
cout < <"请蓝方输入落子位置:" < <endl;
loop2:
cout < <"请输入落子的行数:";
cin>>x;
cout < <"请输入落子的列数:";
cin>>y;
if(weizhi[x][y]=='-')
{
weizhi[x][y]='#';
for(k=0;k <=N;k++)
cout < <setw(3) < <setfill(' ') < <k;
cout < <endl;
for(i=1;i <=M;i++)
{
cout < <setw(3) < <setfill(' ') < <i;
for(j=1;j <=N;j++)
cout < <setw(3) < <setfill(' ') < <weizhi[i][j];
cout < <endl;
}
}
else
{
cout < <"你不能在这落子,请重新选择落子位置:";
goto loop2;
}
}
//判断胜利
for(i=1;i <=M-4;i++)
{
for(j=1;j <=N-4;j++)
{
if(weizhi[i][j]=='#' && weizhi[i][j+1]=='#' && weizhi[i][j+2]=='#' && weizhi[i][j+3]=='#' && weizhi[i][j+4]=='#')
{
cout < <"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='#' && weizhi[i+1][j]=='#' && weizhi[i+2][j]=='#' && weizhi[i+3][j]=='#' && weizhi[i+4][j]=='#')
{
cout < <"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(weizhi[i][j]=='#' && weizhi[i+1][j+1]=='#' && weizhi[i+2][j+2]=='#' && weizhi[i+3][j+3]=='#' && weizhi[i+4][j+4]=='#')
{
cout < <"恭喜蓝方获得简易双人对战五子棋的胜利!耶~~~" < <endl;
flag=1;
break;
}
if(flag==1)
break;
}
}
return 0;
}
