标签:
1 #include <iostream> 2 #define MAXN 100 3 using namespace std; 4 5 int _m[MAXN][MAXN]; 6 7 int main() 8 { 9 //freopen("acm.acm","r",stdin); 10 int i; 11 int j; 12 int n; 13 int sum; 14 int code_r; 15 int code_c; 16 while(cin>>n,n) 17 { 18 code_r = -1; 19 code_c = -1; 20 for(i = 0; i < n; ++ i) 21 { 22 for(j = 0; j < n; ++ j) 23 { 24 cin>>_m[i][j]; 25 } 26 } 27 28 29 for(i = 0; i < n; ++ i) 30 { 31 sum = 0; 32 for(j = 0; j < n; ++ j) 33 { 34 sum += _m[i][j]; 35 } 36 if(sum % 2 != 0) 37 { 38 if(code_r == -1) 39 code_r = i; 40 else 41 { 42 code_r = -2; 43 break; 44 } 45 } 46 if(code_r == -2) 47 break; 48 } 49 50 if(code_r == -2) 51 { 52 cout<<"Corrupt"<<endl; 53 continue; 54 } 55 56 for(j = 0; j < n; ++ j) 57 { 58 sum = 0; 59 for(i = 0; i < n; ++ i) 60 { 61 sum += _m[i][j]; 62 } 63 if(sum % 2 != 0) 64 { 65 if(code_c == -1) 66 { 67 code_c = j; 68 } 69 else 70 { 71 code_c = -2; 72 break; 73 } 74 } 75 } 76 if(code_c == -2) 77 { 78 cout<<"Corrupt"<<endl; 79 continue; 80 } 81 82 if(code_r == -1 && code_c == -1) 83 { 84 cout<<"OK"<<endl; 85 } 86 else 87 { 88 cout<<"Change bit ("<<code_r+1<<","<<code_c+1<<")"<<endl; 89 } 90 91 } 92 }
标签:
原文地址:http://www.cnblogs.com/gavinsp/p/4566743.html