Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
如果你们的程序都可以保证返回0表示正常结束In Reply To:请问1282为什么一直内存溢出?谢谢 Posted by:Hence at 2004-03-22 14:08:52 那我就容易判断了 可惜vc可以不返回值,所以目前是通过错误代码来判断的 而windows系统那个时候不给我返回runtime error,而是内存溢出 可能是由于你的是局部变量,系统就不算内存访问错了,郁闷. > #include <stdio.h> > > int main() > { > const int max=200; > freopen("1282pku.in","r",stdin); > char a[max][max]; > char r[max]; > long int i,j,n,p; > long int t1,t2; > long int year; > scanf("%ld %ld",&n,&p); > for (i=0;i<n;i++) > for (j=0;j<p;j++) {scanf("%ld",&t1);a[i][j]=(int)t1-1;} > year=0; > for (i=0;i<n;i++) r[i]=(int)i; > while (year<1000000000) > { > t1=0;t2=year%p; > for (i=0;i<n;i++) > { > r[i]=a[r[i]][t2]; > if (i==r[i]) t1++; > } > if (t1==n) break; > year++; > } > if (year==1000000000) puts("No one knows."); else printf("%d\n",year+1); > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator