Home > Back-end >  A great god and see what was wrong, 101 judgment than primes
A great god and see what was wrong, 101 judgment than primes

Time:12-01

# include
# include
Int ISPRIME (int n);
The main ()
{
int a;
The scanf (" % d ", & amp; A);
If (ISPRIME (a))
{
Printf (" % d is prime. ", a);
}
The else
{
Printf (" % d is not prime. ", a);
}
}
Int ISPRIME (int n)
{
Int b, c, I;
Double k;
C=0;
K=SQRT (n) + 1;
If (n==1)
Return (0);
Else if (n==2)
Return (3);
Else if (n % 2==0);
Return (0);
For (I=3; i<=k; I +=2)
{
B=n % I;
If (b==0)
C + +;
If (c>
=1)Return (0);
}
The return (1);
}

CodePudding user response:

Save a freshman small rookie

CodePudding user response:

Reference:
 int ISPRIME (int n); 
Int main (int arg c, char * argv [])
{
int a;
The scanf (" % d ", & amp; A);
If (ISPRIME (a))
{
Printf (" % d is prime. \ n1 ", a);
}
The else
{
Printf (" % d is not prime. \ n ", a);
}
System (" pause ");
return 0;
}

Int ISPRIME (int n)
{
If (n<=1) return 0;
If (n==2) return 1;
For (int I=2; iIf I (n %==0) return 0;
return 1;
}

CodePudding user response:

refer to the second floor QZJHJXJ response:
for reference:
 int ISPRIME (int n); 
Int main (int arg c, char * argv [])
{
int a;
The scanf (" % d ", & amp; A);
If (ISPRIME (a))
{
Printf (" % d is prime. \ n1 ", a);
}
The else
{
Printf (" % d is not prime. \ n ", a);
}
System (" pause ");
return 0;
}

Int ISPRIME (int n)
{
If (n<=1) return 0;
If (n==2) return 1;
For (int I=2; iIf I (n %==0) return 0;
return 1;
}

I want to ask me the function of what is going wrong?
  • Related