请求各位大神帮助

花溪 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;
}
...全文
72 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
花溪 2012-04-13
  • 打赏
  • 举报
回复
谢谢你们,很感激!·
赵4老师 2012-04-13
  • 打赏
  • 举报
回复
在占用内存空间较大的局部数组声明的前面加static将其从堆栈数据段挪到全局数据段即可。
hen_hao_ji 2012-04-13
  • 打赏
  • 举报
回复
说错了,不是至少一百,最多不会超过一百。。。
[Quote=引用 1 楼 的回复:]
The first line of each test case contains one integer n (n<100),

兄弟数组开小了,至少一百:int b[100][100]={0}
[/Quote]
hen_hao_ji 2012-04-13
  • 打赏
  • 举报
回复
The first line of each test case contains one integer n (n<100),

兄弟数组开小了,至少一百:int b[100][100]={0}

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧