void main (){ int i=100,c,a;while(i<=200){ c=2;while(c<=i)//只要除到这个数的平方根就行了、{ a=i%c;/*你这个绝对不行的,素数一般是要使用除的,而不是求余 比如 150不是素数。但是150%10=0 这个是求余*/ if(a==0){ printf("%d\n",i);c=i+1;//在已经知道...
int main(){ int i,j,flag;for(i=100;i<200;i++){ for(j=2,flag=1;j<=sqrt(i);j++){ if(i%j==0){ flag=0;break;} } if(flag)printf("%d ",i);} return 0;}
include<stdio.h>#include<math.h>int main(){int num,sum=0,i,flat=1;for(num=100;num<200;num++){for(i=2;i<=(int)sqrt((double)num);i++){if(num%i==0){flat=0;break;}}if(flat){printf("%d ",num);sum+=num;}flat=1;}printf("\n100~200之间的素数和为:%d\n",sum...
include <stdio.h>int isPrime(int i){ int x;int y = (int)ceil(sqrt(i)); if (i%2==0 || i<2)return 0; for (x=3; x<=y; x++)if (i%x == 0)return 0; return 1;}int main(void){ int c = 0, i; for (i=100; i<=200; i++)if (isPrime(i)){ printf("...
printf("Open the file failure...\n"); exit(0); } for(i=101;i<200;i+=2){ for(j=3;(k=j*j)<=i;j+=2) if(!(i%j)) break; if(k>i) fprintf(fp,++l%5 ?