#include <stdio.h>
int main(void){
//找出100到200以内的所有素数
int x;
int count=0;//统计素数个数
for(x=100;x<=200;x++){
int i;
int isPrime=1;
for(i=2;i<x;i++){
if(x%i==0){
isPrime=0;
break;
}
}
if(isPrime==1){
count++;
printf("%d ",x);
}
}
printf("\n素数个数=%d",count);
return 0;
}
//运行结果:
101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197
199
素数个数=21
Process exited after 1.138 seconds with return value 0
请按任意键继续. . .