第二点和第八个点的数据是啥?

各种过不了,也是蛮佩服自己的。
顺便贴上代码

#include <iostream>
#include <cstdio>
using namespace std;
int n,a[10][10],tot,flag=1;
bool qvyu(int o,int p){
    int jiahe=0;
    for(int i=o;i<=o+2;i++)
        for(int j=p;j<=p+2;j++)
        jiahe = jiahe + a[i][j];
    if(jiahe != 45) return false;
    else return true; 
}
bool jiancha(int x,int y){
    for(int i=x;i<=9;i=i+3)
        for(int j=y;j<=9;j=j+3)
            if( ! qvyu(i,j) )  return false;
        return true;
}
int main(){
    freopen("test.in","r",stdin);
    cin>>n;
    for(int z=1;z<=n;z++){
        if(z != 1) getchar();
        for(int i=1;i<=9;i++){
            for(int j=1;j<=9;j++){
                cin>>a[i][j];
                tot = a[i][j] + tot;    
            }
            if(tot != 45 ) {
                cout<<"Wrong"<<endl;
                tot = 0;
                flag = 0;
                break;
            }
            tot = 0;
    }
    if(flag == 0)  continue;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            tot = a[j][i] + tot;    
            }
        if(tot != 45 ) {
            cout<<"Wrong"<<endl;
            tot = 0;
            flag = 0;
            break;
        }
        tot = 0;
    }
    if(flag == 0) continue;
    if ( jiancha(1,1) )  {   //在这块出错的  我这里设置的把9*9 划分成9块 3*3 判断 
        cout<<"Right"<<endl;
        }
    else cout<<"Wrong"<<endl;
    
    }
    return 0;
}

0 条评论

目前还没有评论...

信息

ID
1335
难度
4
分类
模拟 点击显示
标签
递交数
5130
已通过
1978
通过率
39%
被复制
20
上传者