#include<iostream>
#include<string>
#include<windows.h>
#include<conio.h>
using namespace std;
int main()
{
int player=1; int qiPan[19][19]; for(int h=0;h<19;h++) {
for(int l=0;l<19;l++)
{
qiPan[h][l]=0; }
}
int qiPanTwo[19][19]; for(int h=0;h<19;h++) {
for(int l=0;l<19;l++)
{
qiPanTwo[h][l]=0; }
}
int X=9; int Y=9;
qiPan[9][9]=8;
for(int h=0;h<19;h++)
{
for(int l=0;l<19;l++)
{
if(qiPan[h][l]==8)
{
cout<<"╋";
}
else if(qiPanTwo[h][l]==0)
{
cout<<"·";
}
else if(qiPanTwo[h][l]==1)
{
cout<<"●";
}
else if(qiPanTwo[h][l]==2)
{
cout<<"○";
}
}
cout<<endl;
}
while(true)
{
char xx=getch(); switch(xx) {
case 'w': Y=Y-1; qiPan[Y][X]=8; qiPan[Y+1][X]=0; break;
case 's': Y=Y+1;
qiPan[Y][X]=8;
qiPan[Y-1][X]=0;
break;
case 'a': X=X-1;
qiPan[Y][X]=8;
qiPan[Y][X+1]=0;
break;
case 'd': X=X+1;
qiPan[Y][X]=8;
qiPan[Y][X-1]=0;
break;
case 'j': if(player==1) {
qiPanTwo[Y][X]=1; player=2; }
else if(player==2)
{
qiPanTwo[Y][X]=2;
player=1;
}
break;
}
system("cls");
for(int h=0;h<19;h++)
{
for(int l=0;l<19;l++)
{
if(qiPan[h][l]==8)
{
cout<<"╋";
}
else if(qiPanTwo[h][l]==0)
{
cout<<"·";
}
else if(qiPanTwo[h][l]==1)
{
cout<<"●";
}
else if(qiPanTwo[h][l]==2)
{
cout<<"○";
}
}
cout<<endl;
}
int shu=1,heng=1,pie=1,na=1; for(int i=1;i<=4;i++) {
if(qiPanTwo[Y+i][X]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
shu++;
else
break;
}
for(int i=1;i<=4;i++) {
if(qiPanTwo[Y-i][X]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
shu++;
else
break;
}
for(int i=1;i<=4;i++) {
if(qiPanTwo[Y][X-i]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
heng++;
else
break;
}
for(int i=1;i<=4;i++) {
if(qiPanTwo[Y][X+i]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
heng++;
else
break;
}
for(int i=1;i<=4;i++) {
if(qiPanTwo[Y+i][X-i]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
pie++;
else
break;
}
for(int i=1;i<=4;i++) {
if(qiPanTwo[Y-i][X+i]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
pie++;
else
break;
}
for(int i=1;i<=4;i++) {
if(qiPanTwo[Y+i][X+i]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
na++;
else
break;
}
for(int i=1;i<=4;i++) {
if(qiPanTwo[Y-i][X-i]==qiPanTwo[Y][X]&&qiPanTwo[Y][X]!=0)
na++;
else
break;
}
if(shu==5||heng==5||pie==5||na==5)
{
if(qiPanTwo[Y][X]==1)
{
cout<<"白子获胜!";
system("pause");
break;
}
else
{
cout<<"黑子获胜!";
system("pause");
break;
}
}
}
return 0;
}