// Error Correction.cpp : Defines the entry point for the console application. // #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[])
{
int
n,i=0,j=0,A[100][100],sum1=0,sum2=0,rc,cc,tru=0,rd,cd;
while(scanf("%d",&n))
{
if(n!=0)
{
rc=0;cc=0;tru=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&A[i][j]);
}
}
for(i=0;i<n;i++)
{
sum1=0;
sum2=0;
for(j=0;j<n;j++)
{
sum1=sum1+A[i][j];
sum2=sum2+A[j][i];
}
if(sum1%2!=0
|| sum2%2!=0)
{
if(sum1%2!=0)
{
rc++;
rd=i;
}
else
if(sum2%2!=0)
{
cc++;
cd=i;
}
if(rc>1
|| cc>1)
{
tru=1;
break;
}
}
}
if(rc==0
&& cc==0)
{printf("OK\n");}
else
if(tru==1)
{printf("Corrupt\n");}
else
if(rc!=cc)
{printf("Corrupt\n");}
else
if(rc==1 && cc==1)
{
printf("Change bit
(%d,%d)\n",rd+1,cd+1);
}
}
else
{return 0;}
}
}
4
1 0 1 0
0 0 0 0
1 1 1 1
0 1 0 1
OK
4
1 0 1 0
0 0 1 0
1 1 1 1
0 1 0 1
Change bit (2,3)
4
1 0 1 0
0 1 1 0
1 1 1 1
0 1 0 1
Corrupt
No comments:
Post a Comment