1 #include<iostream> 2 using namespace std; 3 #define max 10000 4 bool num[10002]; 5 int pan1,pan2; 6 void foundprime(){ 7 for(int i=2;i<=100;i++) 8 { 9 for(int j=i*i;j<=max;j+=i) 10 { if(num[j]==true) 11 num[j]=false; 12 } 13 } 14 } 15 void chazhao(int number){ 16 for(int i=2;i<=number/2;i++) 17 { 18 if(num[i]==true) 19 { 20 if(num[number-i]==true) 21 { 22 23 pan1=i;pan2=number-i; 24 } 25 } 26 } 27 } 28 29 30 int main() 31 { int number; 32 33 memset(num,true, sizeof(num)); 34 num[0]=num[1]=false; 35 foundprime(); 36 while(scanf("%d",&number)!=EOF) 37 { 38 39 chazhao(number); 40 cout<<pan1<<" "<<pan2<<endl; 41 } 42 return 0; 43 }
时间: 2024-11-18 05:32:59