#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;}
#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;}