include
void main()
{int i,j,n,m;
i=2;
while(i<101)
{m=1;n=i/2;j=2;
while(j<=n)
{ if(i%j==0)
{m=0;
breake;
}
j++;
}
if(m)
cout<i++;
}
}
2.用do...while
#include
void main()
{int i,j,n,m;
i=2;
do
{m=1;n=i/2;j=2;
do
{if(i%j==0)
{m=0;
breake;
}
j++;
}while(j<=n);
if(m)
cout<i++;
}while(i<101);
}
3.用for
# include
void main()
{int i,j,n,m;
for(i=2;i<101;i++)
{m=1;
n=i/2;
for(j=2;j<=k;j++)
{if(i%j==0)
{m=0;
breake;
}
}
if(m)
cout<}}