自己刚写的程序,你试试看
#include "math.h"
#include <stdio.h>
int main()
{
int m,i,k,h=0,leap=1;
printf("\n");
for(m=1;m<=10000;m++)
{
k=sqrt(float(m+1));
for(i=2;i<=k;i++)
if(m%i==0)
{
leap=0;
break;
}
if(leap)
{
printf("%-8d",m);
h++;
if(h%10==0)
printf("\n");
}
leap=1;
}
printf("\nThe total is %d",h);
}