| ||||||||||
| 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 | |||||||||
各位帮我看下,错在哪儿了?晕#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char isprime[1000001];
int main()
{
int i,j;int N;
for(i = 2; i*i <= 100000; ++i){
if(isprime[i] == 0)
for(j = 2*i; j <=100000; j += i){
isprime[j] = 1;
}
}
// ok;
while(1){
scanf("%d",&N);
if(N == 0) break;
for(i = 3; i <= N/2; i+=2){// 必须是<=. 6 = 3 + 3
if(isprime[i]==0 && isprime[N-i]==0){
printf("%d = %d + %d\n", N,i,N-i);
break;
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator