矩阵简单应用,求奇偶
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
int N,i,j,nr,nb,t1,t2,cr,cb;
int ar[110][110];
while(cin>>N){
if(N==0)break;
nr=0;
nb=0;
for(i=0;i<N;i++){
t2=0;
for(j=0;j<N;j++){
cin>>ar[i][j];
t2+=ar[i][j];
}
if(t2%2!=0){
nr++;
cr=i;
}
}
for(i=0;i<N;i++){
t1=0;
for(j=0;j<N;j++){
t1+=ar[j][i];
}
if(t1%2!=0){
nb++;
cb=i;
}
}
if(nr==0 && nb==0){
cout<<"OK"<<endl;
}
if(nr==1 && nb==1){
printf("Change bit (%d,%d)\n",cr+1,cb+1);
}
if(nr>1 || nb>1){
printf("Corrupt\n");
}
}
return 0;
}
/*
4
1 0 1 0
0 0 0 0
1 1 1 1
0 1 0 1
4
1 0 1 0
0 0 1 0
1 1 1 1
0 1 0 1
4
1 0 1 0
0 1 1 0
1 1 1 1
0 1 0 1
0
*/