#include <stdio.h> #include <stdlib.h> #include<math.h> #define NUM 320 int number[NUM]; 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, j, count = 0; for(j=0, i=3; i<=1993; i+=2) if(prime(i)) number[j++] = i; for(j--; number[j]>1898; j--) { for(i=0; number[j]-number[i]>1898; i++) if(number[j]-number[i]==1898) printf("%d.%3d,%d\n",++count, number[i], number[j]); } return 0; } 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/44816157