Test point 0 s and 1 s have been wrong
#include
#include
# include & lt; Math. H>
using namespace std;
Int main () {
Int left, right, t=0, order=1, j=0;
Bool re=false;
Int ss [10001];
Ss [0]=2;
The scanf (" % d % d ", & amp; Left, & amp; Right);
if(! Left) {
Left=1;
}
For (int I=2; Order
For (j=2; j<=SQRT (I); J++) {
If (I % j==0)
{
Re=false;
break;
}
}
If (re) {
Ss [order++]=I;
}
Re=true;
}
Left -=1;
Right -=1;
While (left<={right)
t++;
If (t % 10==0 | | left==right) {
T=0;
}
Printf (" % d % c ", ss [left++], t? The '*', '\ 0');
If (t==0) printf (" \ n ");
}
return 0;
}
CodePudding user response:
# include & lt; Algorithm>
# include & lt; Cstdio>
# include & lt; Math. H>
using namespace std;
Int main () {
Int left, right, t=0, order=1, j=0;
Bool re=false;
Int ss [10001];
Ss [0]=2;
The scanf (" % d % d ", & amp; Left, & amp; Right);
if (! Left) {
Left=1;
}
For (int I=2; OrderFor (j=2; j<=SQRT (I); J++) {
If (I % j==0) {
Re=false;
break;
}
}
If (re) {
Ss [order++]=I;
}
Re=true;
}
Left -=1;
Right -=1;
While (left<={right)
t++;
If (t % 10==0 | | left==right) {
T=0;
}
If (t==0) {
Printf (" % d \ n ", ss [left++]);
} else {
Printf (" % d ", ss [left++]);
}
}
return 0;
}
CodePudding user response:
Code no problemCodePudding user response:
# include
#include
# include & lt; Math. H>
using namespace std;
Int is_prime (int n);
The static void swap (int * a, int * b);
Int main ()
{
Int I=2, j=0;
Int left, right, CNT=0;
The scanf (" % d % d ", & amp; Left, & amp; Right);
If (left & gt; Right)
Swap (& amp; Left, & amp; Right);
While (1) {
{if (is_prime (I))
Cnt++;
If (left & lt;=CNT & amp; & CNT & lt;={right)
j++;
Printf (" % d % c ", I, j % 10? "' : '\ n');
}
If (CNT & gt; Right)
break;
}
i++;
}
Putchar (10);
/*
Int left, right, t=0, order=1, j=0;
Bool re=false;
Int ss [10001];
Ss [0]=2;
The scanf (" % d % d ", & amp; Left, & amp; Right);
if(! Left) {
Left=1;
}
For (int I=2; Order{
For (j=2; j<=SQRT (I); J++) {
If (I % j==0)
{
Re=false;
break;
}
}
If (re) {
Ss [order++]=I;
}
Re=true;
}
Left -=1;
Right -=1;
While (left<={right)
t++;
If (t % 10==0 | | left==right) {
T=0;
}
Printf (" % d % c ", ss [left++], t? The '*', '\ 0');
If (t==0) printf (" \ n ");
}
*/
return 0;
}
Int is_prime (int n)
{
int i;
If (n & lt;
=1)return 0;
For (I=2; I & lt;=SQRT (n); I++) {
If I (n %==0)
return 0;
}
return 1;
}
The static void swap (int * a, int * b)
{
Int TMP=* a;
*=* b;
* b=TMP;
}
For your reference ~
~ useless array, use the cycle
CodePudding user response:
CodePudding user response: