how should change?

#include
# define N
Void Siftprime (int a [], int n);
Void DoublePrime (int a [], int n);
//screen method prime
Void Siftprime (int a [], int n)
{
Int I, j, m
For (I=2; i<=n; I++)
{
A [I]=I;
}
For (I=2; i<=n; I++)
{
For (j=I + 1; J
If (a [I]!=0 & amp; & A [j]!=0 & amp; & A [j] a [I] %==0)
A [j]=0;
}
}
}
Void DoublePrime (int a [], int n)
{
int i;
For (I=m; i
If (a [I]!=0 & amp; & A [I + 2]!=0)
Printf (" % 4 d/% d ", I, I + 2);
}
}
Int main ()
{
Int a [N + 1);
Siftprime (a, N);
DoublePrime (a, N);
return 0;
}
CodePudding user response:
Wrong, the code is this:#include
#include
# define N 100
Void Siftprime (int a [], int n);
Void DoublePrime (int a [], int n);
//screen method prime
Void Siftprime (int a [], int n)
{
int i,j;
For (I=2; i<=n; I++)
{
A [I]=I;
}
For (I=2; i<=n; I++)
{
For (j=I + 1; J
If (a [I]!=0 & amp; & A [j]!=0 & amp; & A [j] a [I] %==0)
A [j]=0;
}
}
}
Void DoublePrime (int a [], int n)
{
int i;
For (I=3; i
If (a [I]!=0 & amp; & A [I + 2]!=0)
Printf (" % 4 d/% d ", I, I + 2);
}
}
Int main ()
{
Int a [N + 1);
Siftprime (a, N);
DoublePrime (a, N);
return 0;
}
CodePudding user response:
# include
Void main ()
{
Int m, n;
The scanf (" % d % d ", & amp; M, & amp; N);
For (int j, I=m; I & lt;=n; I++)
{
For (j=2; J & lt; i; J++)
{
If (I % j==0)
break;
}
If (j==I) printf (" % d ", I);
}
}
CodePudding user response:
Can't read

CodePudding user response:
Reference://sieve method primes within N
# include
Int main ()
{
int n;
Bool prime [1000].
for(int i=0; i<1000; I++)
{
Prime [I]=0;//assume that all Numbers are prime Numbers
}
The scanf (" % d ", & amp; N);
for(int i=2; i<=n; I++)
{
If (prime [I]==0)//marked all multiples of each time will be a prime is a prime number
{
For (int j=I * 2; J<=n; J=j + I)//from a multiple of 2 times the start tag prime is a prime
{
Prime [j]=1;
}
}
}
for(int i=2; i<=n; I++)
{
If (prime [I]==0) printf (" % d \ n ", I);
}
//system("pause");
return 0;
}