Home > Back-end >  Pray god help to see if the problem is? This is an even number into the sum of two prime Numbers
Pray god help to see if the problem is? This is an even number into the sum of two prime Numbers

Time:11-22

#include

Int prime (int n)
{
Int k, d;
K=SQRT (n);
If (n==1)
return 0;
If (n==2)
return 1;
For (d=2; D<=k; D++)
{if (n % d==0)
return 0;
break; }
If (d> K)
return 1;
}
Int main ()
{
Int a, b, c, d, n.
Printf (" please enter an even number ");
The scanf (" % d ", & amp; n);
If (n==2)
Printf (" \ n the value cannot be broken down into two prime Numbers ");
For (a=1; a{b=n - a;
C=prime (a);
D=prime (b);
If (c==1 & amp; & D==1)
Printf (" \ n + % d % d=% d \ n ", n, a, b); }
return 0;
}

CodePudding user response:

In accordance with the original poster, modified as follows:
 # include & lt; stdio.h> 
#include
Int prime (int n)
{
int i;
for(i=2; i<=SQRT (n); I++)
If I (n %==0) return 0;
return 1;
}

Int main (int arg c, char * argv [])
{
Int a, b, c, d, n.
Printf (" please enter an even number (n> 3) : ");
The scanf (" % d ", & amp; n);
If (n<3 | | n % 2!=0)
{
Printf (" this value does not meet the input requirements. \ n ");
//return 0;
}
The else
{
For (a=2; a<=n/2; +)
{
B=n - a;
C=prime (a);
D=prime (b);
If (c==1 & amp; & D==1)
Printf (" % d=% d + % d \ n ", n, a, b);
}
}
system("pause");
return 0;
}
  • Related