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 |
什么是RUN TIME ERROR?郁闷死了!答案明明正确,为啥总是RUN TIME ERROR?大侠们帮小弟看一下,谢谢了!#include <stdio.h> #include <stdlib.h> int judge(int *a,int m); void init(int *a,int m); int judge(int *a,int m) { int i,j,sum=0; for(j=1;j<=m;j++) for(i=1;i<=m;i++) if(i%j==0) if(*(a+2*i)) *(a+2*i)=0; else *(a+2*i)=1; for(i=1;i<=m;i++) if(*(a+2*i)) sum++; return sum; } void init(int *a,int m) { int i; for(i=1;i<=m;i++) *(a+2*i)=0; } void main() { int n,i,j=0,m; int *a,*b; scanf("%d",&n); b=(int *)malloc(n*sizeof(int)); while(j<n) { scanf("%d",&m); a=(int *)malloc((m+1)*sizeof(int)); init (a,m); *(b+2*j)=judge(a,m); j++; } for(i=0;i<n;i++) printf("%d\n",*(b+2*i)); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator