请求各位大神帮助
花溪 2012-04-13 12:51:47 谁能帮我看一下Error Correction pku 2260 的代码我测试都通过了,就是提交不了唉!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int a[4][4]={{1,0,1,0},{0,0,0,0},{1,1,1,1},{0,1,0,1}};
int main()
{
int n;
while(scanf("%d",&n)!=EOF&&n!=0)
{
int b[10][10]={0},sumh=0,suml=0,clum=0,cow=0,m=0,p=0,m1=0,p1=0,g,h,k,l;
// memset(b,0,sizeof(b));
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
{
scanf("%d",&b[i][j]);
}
for(g=0;g<n;g++)//行校对
for(h=0;h<n;h++)
{
if(b[g][h]==1)sumh++;//统计这行一的个数
if(h==n-1)
{
if(sumh%2==0)
{
clum++;
sumh=0;
} //判断这一行的奇偶
else
{
if(m1==0)m=g+1; //记录行号,并看有几行不为偶
m1++;
sumh=0;
}
}
}
// printf("%d %d\n",m,m1);
for(l=0;l<n;l++) //列校对
for(k=0;k<n;k++)
{
if(b[k][l]==1)suml++;
if(k==n-1)
{
if(suml%2==0)
{
cow++;
suml=0;
}
else
{
if(p1==0)p=l+1;
p1++;
suml=0;
}
}
}
//printf("%d %d\n",p,p1);
if(m1==0&&p1==0) printf("OK\n");
else if(m1==1&&p1==1) printf("Change bit (%d,%d)\n",m,p);
else printf("Corrupt\n");
}
//system("pause");
return 0;
}