大一0基础小白用最基础C写哥德巴赫猜想
程序员文章站
2022-06-24 09:42:45
#include int main (){ int a,b,c,k,count1,count2; for(a=4;a<=1200;a=a+2){ for(b=2;b<=a/2;b++){ count1=0; for(c=2;c<=b-1;c++){ if(b%c==0) count ......
#include <stdio.h>
int main (){
int a,b,c,k,count1,count2;
for(a=4;a<=1200;a=a+2){
for(b=2;b<=a/2;b++){
count1=0;
for(c=2;c<=b-1;c++){
if(b%c==0)
count1++;}
if(count1==0){
k=a-b;
count2=0;
for(c=2;c<=k-1;c++){
if(k%c==0)
count2++;
}
if(count2==0){
printf("%d=%d+%d\n",a,b,k);
break;
}
}
}
}
}