|
本帖最后由 981013 于 2014-8-16 10:40 编辑
先贴修改后的代码:
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
int main()
{
int x=2,z=0,n=0,y;
while(x<=100)
{
for(y=1;y<=x;y++)
{
if(x%y==0)
z=z+1; //求因数数量
}
if(z<=2) //判断是否为质数
{
n=x+n;
printf("%d\n",n);
}
x=x+1;
z=0;
}
system("pause");
return 0;
}[/mw_shl_code] |
|