茅侃侃
本题简单的C算法#include<stdio.h>int main (){ int i,m ;int a[27]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103};//105以内的所有素数,下面附的有打印N以内所有素数的m=0;for(i=0;i<26;i++)if(a[i+1]-a[i ]==2)m++;printf("%d",m);return 0;}////这部分是计算素数的算法,本题并不一定需要,给你参考一下附:#include<stdio.h>#include<stdlib.h>int main(){int i,j,n;printf("请输入n:");scanf("%d",&n);for(j=2;j<=n;j++){i=2;while(i<j){if(j%i==0)break;i++;}if(i==j)printf("%d is prime\n",j);elseprintf("%d is no prime\n",j);}system("pause");return 0;}