int
isPrime(int n)那部分好像不行,输入3,30,只打印3, 后面就通不过,大侠们帮忙看看啊,#include<stdio.h>
#include <conio.h>
#include <math.h>
int isPrime(int);
int findPrime (int, int ) ;
int findSquare(int,int);
int sum;
int main (void)
{
int x,y,sumPrime;
printf("Enter two numbers\n");
scanf("%d %d",&x,&y);
while(x <= y)
{
printf("Prime: ");
sumPrime=findPrime( x, y);
printf("\nSquare: ");
findSquare(x,y);
printf("\nsum of all primes and squares:%d",sum);
printf("\nEnter two numbers");
scanf("%d %d",&x,&y);
}
return 0;
}
int findPrime (int a, int b )
{
int sumPrime=0,c=0;
while(a<=b)
{
if(isPrime(a))
{
printf(
"%d ",a);c++;
sumPrime+=a;
a++; }
}
printf("\nPrime count = %d\n",c); return 0 ;}
int
isPrime(int n){
int i;for(i=2;i<n;i++) if(n%i==0) return 0;
return 1;
}
int
findSquare ( int a,int b){
int i,t,c=0,sumSquare = 0;for(i=2; i*i<=b;i++)
{
printf(
"%d ", i*i);c++;
sumSquare+=i*i;
}
printf(
"\nsumsquare is %d",sumSquare);printf(
"\nSquare count = %d\n",c); return sumSquare;}