回覆列表
  • 1 # 使用者52510796211

    #include <stdio.h>#include <math.h>void show(int a[],int n) {for(int i = 0; i < n; ++i)printf("%d ",a[i]);printf("\n");}int Primes(int m,int n,int a[]) {int i,j,flag,counter = 0;if(m % 2 == 0) m++;for(i = m;i <= n;i += 2) {flag =

    1;for(j =

    2;j < sqrt(i) + 1;j++) {if(i % j == 0) {flag = 0;break;}}if(flag) a[counter++] = i;}return counter;}int main() {int a[100],k;int m = 200,n = 300;k = Primes(m,n,a);printf("%d到%d之間的迴文素數有%d個:\n",m,n,k);show(a,k);return 0;}

  • 中秋節和大豐收的關聯?
  • 鉑金黃金,白金區別?