Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

改来改去原来C比C++严格这么多

Posted by hmh0512 at 2009-07-30 18:16:35 on Problem 2262
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator