c语言问题20

来源:百度知道 编辑:UC知道 时间:2024/07/04 12:10:53
用程序验证一个大于4的偶数总能表示为两个素数之和。

程序在win-tc和Dev-c++下调试通过。
#include "stdio.h"
#include "math.h"

main()
{ int a,b,c,d;
printf("Please input an even(>4):\n");
scanf("%d",&a);
for(b=3;b<=a/2;b+=2)
{ for(c=2;c<=sqrt(b);c++)
if(b%c==0) break;
if(c>sqrt(b))
d=a-b;
else
continue;
for(c=2;c<=sqrt(d);c++)
if(d%c==0) break;
if(c>sqrt(d))
printf("%d=%d+%d\n",a,b,d);
}
getch();
}