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 |
Re:改来改去原来C比C++严格这么多In Reply To:改来改去原来C比C++严格这么多 Posted by:hmh0512 at 2009-07-30 18:16:35 > #include<string.h> > #include<stdio.h> > #define m 1000000 > int a[m]; > void Prime() > { > int i,j; > memset(a,0,sizeof(a)); > a[0]=a[1]=1; > for(i=2;i<m;i++) > if(a[i]==0) > for(j=i+i;j<m;j+=i) > if(a[j]==0) > a[j]= 1; > } > main() > { > int n,i,j; > Prime(); > while(scanf("%d",&n)!=EOF) > { > if(n<6||n&1||n==0) > break; > for(i=3;i<=n/2;i++) > if(a[i]==0&&a[n-i]==0) > { > printf("%d = %d + %d\n",n,i,n-i); > break; > } > } > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator