#include <stdio.h>
#include <stdlib.h>
int mx,my;
int cnt=0,cntt=0;
char arr[20][20] =
{
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
{'*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*','*'},
};
char xs(void)
{
for(int i=0;i<20;i++)
{
for(int j=0;j<20;j++)
{
printf("%c ",arr[i][j]);
}
printf("\n");
}
}
int lz(void)
{
while(1)
{
if(cnt % 2 == 0)
{
printf("请落白子\n");
}
else
{
printf("请落黑子\n");
}
while(scanf("%d%d",&mx,&my)==2)
{
if(mx >= 20 || mx < 0 || my >= 20 || my < 0)
{
printf("请下在正确位置\n");
continue;
}
else if( arr[mx][my] != '*')
{
printf("该位置已有棋子请重新落子\n");
continue;
}
if(cnt % 2 == 0)
{
arr[mx][my] = '&';
cnt++;
return 0;
}
else
{
arr[mx][my] = '@';
cnt++;
return 0;
}
}
}
}
int tj(int m_x,int m_y)
{
while(1)
{
if(mx+m_x < 0 || mx+m_x >= 20 || my+m_y < 0 || my+m_y >= 20)
{
return;
}
else
{
if(arr[mx+m_x][my+m_y]==arr[mx][my])
{
cntt++;
if(m_x < 0)m_x--;
else m_x++;
if(m_y < 0)m_y--;
else m_y++;
}
else return;
}
}
}
int pd(void)
{
tj(1,1);
tj(-1,-1);
if(cntt >= 4)
{
return 1;
}
cntt = 0;
tj(-1,1);
tj(1,-1);
if(cntt >= 4)
{
return 1;
}
cntt = 0;
tj(-1,0);
tj(1,0);
if(cntt >= 4)
{
return 1;
}
cntt = 0;
tj(0,1);
tj(0,-1);
if(cntt >= 4)
{
return 1;
}
cntt = 0;
return 0;
}
int main(int argc,const char* argv[])
{
for(;;)
{
system("clear");
xs();
lz();
if(pd()==1)
{
system("clear");
xs();
if(cnt % 2 == 1)
{
printf("白子&胜利");
}
else
{
printf("黑子@胜利");
}
return 0;
}
}
return 0;
}