C语言实现如下:include<stdio.h>#include<math.h>#include<stdlib.h>void main(){int n,i,b=1;scanf("%d",&n);if (n==1) {printf("1既不是质数,也不是合数\n");exit(0);}for(i=2;i<=(int)sqrt(n);i++){if (n%i==0) {b=0;break;}}if (b) printf("%d是质数\n"...
for(a=2;a<=100;a++){ for(i=2,t=0;i<a;i++) { if(a%i==0) { t=1; break; } } if(t==0) { cout<<a<<" "; }}