/*
2000以内的不小于4的正偶数都能分解成两个素数之和(验证这个猜想的正确性)
*/
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int prime(int m);
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int i;
int n;
while(scanf("%d", &n) != EOF)
{
int ok = 0;
for(i=2; i<=n/2; i++)
{
if(prime(i))
if(prime(n-i))
{
printf("%d %d\n", i, n-i);
ok = 1;
}
if(i!=2)
i++;
if(ok)
break;
}
}
}
int prime(int m)
{
int i;
int k = sqrt(m);
for(i=2; i<=k; i++)
if(m%i==0)
return 0;
return 1;
}
原文地址:http://blog.csdn.net/orangeisnotapple/article/details/44816061