以下程序满足你的要求,在tc2.0下已调试通过:
#include
"stdio.h"
#include
"stdlib.h"
#include
"math.h"
main()
{
int
i,j,m,n,k,h=0,leap=1;
loop:
printf("\nPlease
input
two
numbers
m
and
n:(m>1,n>m)\n");
scanf("%d%d",&m,&n);
if(m<=1||n<=m)
{
printf("Input
error!
Please
input
again!");
goto
loop;
}
printf("\The
prime
numbers
between
%d
and
%d
are:\n",m,n);
for(i=m;i<=n;i++)
{
k=sqrt(i);
for(j=2;j<=k;j++)
if(i%j==0)
{
leap=0;
break;
}
if(leap)
{
printf("%-4d",i);
h++;
if(h%5==0)
printf("\n");
}
leap=1;
}
printf("\nThe
total
is
%d.",h);
}