当先锋百科网

首页 1 2 3 4 5 6 7

很古老也很简单的游戏,可是判定规则真的好多好无语啊。。。。。

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define ls rt<<1
#define rs ls1
#define lson l,mid,ls
#define rson mid+1,r,rs
#define middle (l+r)>>1
#define eps (1e-9)
#define clr_all(x,c) memset(x,c,sizeof(x))
#define clr(x,c,n) memset(x,c,sizeof(x[0])*(n+1))
#define MOD 1000000007
#define inf 100000007
#define pi acos(-1.0)
#define for(i,a,b) for(int i=(a);i<(b);i++)
#define M 200000+5
char g[5][5];
int main(){
    int T,i,j,c1,c2,f1,f2;
    for(i,0,3)gets(g[i]);
    c1=0;c2=0;
f1=0;f2=0;
for(i,0,3)if(g[i][0]==g[i][1]&&g[i][0]==g[i][2])
if(g[i][0]=='X')     f1=1;
else if(g[i][0]=='0')f2=1;
for(i,0,3)if(g[0][i]==g[1][i]&&g[0][i]==g[2][i])
if(g[0][i]=='X')     f1=1;
else if(g[0][i]=='0')f2=1;
if(g[0][0]==g[1][1]&&g[0][0]==g[2][2])
if(g[0][0]=='X')     f1=1;
else if(g[0][0]=='0')f2=1;
if(g[0][2]==g[1][1]&&g[1][1]==g[2][0])
if(g[1][1]=='X')     f1=1;
else if(g[1][1]=='0')f2=1;
    for(i,0,3)
for(j,0,3){
if(g[i][j]=='X')     c1++;
else if(g[i][j]=='0')c2++;
}
if(c1==c2||(c1==(c2+1))){
if(f1==1&&f2==1)  puts("illegal");
else if(f1==1&&f2==0)
if(c1==(c2+1))puts("the first player won");
else  puts("illegal");
else if(f1==0&&f2==1)
if(c1==c2)  puts("the second player won");
else      puts("illegal");
else{
if((c1+c2)==9)puts("draw");
else if((c1+c2)<9){
if(c1==c2)   puts("first");
else if((c1-1)==c2)puts("second");
}else
puts("illegal");
}
}else
puts("illegal");
    return 0;
}