-
What does twin primes mean?
-
If both n and n+2 are primes, then these two numbers are twin primes.
-
#include
using namespace std;
Twin primes: Pairs of prime numbers that differ by 2.
bool prim(int m) determines whether a number is prime {if(m<2).
return false;
else if(m==2)
return true;
elsefor(int i=2;i=3;i--)int j=i-2;
if(prim(i)&&prim(j))
cout<
-
Landlord, this program of yours has a problem with grammar, and the logic problem is even more serious. Frankly, it can't be changed.
In this case, you should write a function to determine whether an integer is prime, and then loop it in the main function. The procedure is simple and easy to understand.
#include
#include
using namespace std;
bool isprime(int n)
return true;
int main()}
-
If is inside the for loop, and there is no if structure on the outside, so using else will cause an error, and the system will not find an if that matches else
-
Truth be told, there are so many mistakes.
Main error: 1 if followed by ().
2 One sentence is finished; It can't be used,
#include
#include
using namespace std;
int sushu(int n);
int main(void)
return 1;
int sushu(int n)
return 1;
To find a prime number (prime number), you only need to find whether it is divisible by a number of 2 to its square, and if there is a number that is divisible, it is not a prime number.
Otherwise prime.
j in main can be replaced by i+2.
Finding the prime starts from 2 and 1 does not count to the maximum value -2 that is sought
I don't understand what the variable score in sushu does.
-
If should be followed by the condition in parentheses, right?
What if you have 10 million? It's not easy to make money, it's easy to spend! You need to have a lifetime of knowledge to go to graduate school, not only do you have endless money, but you can also have a lifetime of knowledge! >>>More