作者在 2008-04-26 22:16:53 发布以下内容
#include<stdio.h>
#include<math.h>
void main()
{unsigned int i,j,sum=0,flag,count;
count=0;
for(i=50;i<=1000;i++)
{flag=0;
for(j=2;j<=sqrt(i);j++)
{if(i%j==0)
{flag=1;break;}
}
if(flag==0)
{sum+=i;
count++;}
}
printf("%4d",sum);
printf("%4d",count);
}
#include<math.h>
void main()
{unsigned int i,j,sum=0,flag,count;
count=0;
for(i=50;i<=1000;i++)
{flag=0;
for(j=2;j<=sqrt(i);j++)
{if(i%j==0)
{flag=1;break;}
}
if(flag==0)
{sum+=i;
count++;}
}
printf("%4d",sum);
printf("%4d",count);
}