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 |
各路高人,帮帮忙,就快考试了。怎么会是RUNTIME ERROR 呢?#include <stdio.h> #include <malloc.h> void main(){ int i,j,n,sum=0,m,l,*p; scanf("%d\n",&l); for(m=0;m<l;m++){sum=0; scanf("%d",&n); p=(int*)malloc(n*sizeof(int));if(!p) free(p); for(j=1;j<=n;j++) p[j]=1; for(j=2;j<=n;j++){ for(i=j;i<=n;i++){ if(i%j==0) p[i]=p[i]*(-1); else p[i]=p[i]*1; } } for(j=1;j<=n;j++){ if(p[j]==1) sum++;} printf("%d\n",sum); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator