戈特enjoy吧 关注:2贴子:488
  • 1回复贴,共1


IP属地:广东1楼2016-11-06 10:08回复
    #include<stdio.h>
    int judge(int squ[3][3]);
    int main(){
    int out;
    int squ[3][3] = {2,2,2,2,2,2,2,2,2};
    int i,j;
    for(int n = 0;n<9;n++){
    scanf("%d %d",&i,&j);
    i-=1;
    j-=1;
    if(n%2 == 0){
    squ[i][j] = 0;
    }
    else{
    squ[i][j] = 1;
    }
    if(judge(squ) >= 0){
    out = judge(squ);
    break;
    }
    }
    if(out == 0){
    printf("甲玩家胜");
    }
    else if(out == 1){
    printf("乙玩家胜");
    }
    else{
    printf("平局");
    }
    return 0;
    }
    int judge(int squ[3][3]){
    int out;
    int i,j;
    int a,b,c,d;
    for(i = 0;i<3;i++){
    a = b = c = d = 0;
    for(j = 0;j<3;j++){
    if(squ[i][j] == 0){
    a+=1;
    }
    else if(squ[i][j] == 1){
    b+=1;
    }
    if(squ[j][i] == 0){
    c+=1;
    }
    else if(squ[j][i] == 1){
    d+=1;
    }
    }
    if(a == 3 || b == 3 || c == 3 || d == 3){
    goto end;
    }
    }
    a = b = c = d = 0;
    for(i = 0;i<3;i++){
    if(squ[i][i] == 0){
    a+=1;
    }
    else if(squ[i][i] == 1){
    b+=1;
    }
    if(squ[i][2-i] == 0){
    c+=1;
    }
    else if(squ[i][2-i] == 1){
    d+=1;
    }
    }
    end:
    if(a == 3 || c == 3){
    return 0;
    }
    else if(b == 3 || d == 3){
    return 1;
    }
    else {
    return -1;
    }
    }


    IP属地:广东2楼2016-11-06 10:08
    回复