验证哥德巴赫猜想
提示: 作者被禁止或删除 内容自动屏蔽
#include <stdio.h> int isSuShu(int nbr); int main(int argc, char *argv[]) { int suShu_index = 0; int suShu[100]; for(int i = 2; i<100; i++){ if(isSuShu(i)){ suShu[suShu_index] = i; suShu_index++; } } int nbr_of_suShu = 0; for(int i = 6; i<100; i++){ if(i % 2 != 0) continue; for(int p = 0; p < suShu_index; p++){ for(int q = 0; q < suShu_index; q++){ if(suShu[p] + suShu[q] == i){ printf("%d = %d + %d ,",i,suShu[p],suShu[q]); goto LI; } } } LI: nbr_of_suShu++; if(nbr_of_suShu % 5 == 0) printf("\n"); } return 0; } int isSuShu(int nbr){ if(nbr<2) return 0; else if (nbr == 2) return 1; int b = 2; while(b <= ( (int) nbr / 2)){ if(nbr % b == 0) return 0; b++; } return 1; }