# include & lt; Math. H>
Int sushu (int N);
Int main ()
{
Int I, N, a;
Scanf_s (" % d ", & amp; N);
For (I=2; I & lt;=N; I++)//output prime
{
A=sushu (N);
If (a)
Printf (" % d \ n ", I);
}
return 0;
}
Int sushu (int N)//judgment prime
{
Int a;
If (N & lt; 2)
return 0;
For (a=2; A. & lt;=SQRT (N); +)
{
If (a==0 N %)
return 0;
The else
continue;
}
return 1;
}
Why didn't enter 100 reaction
CodePudding user response:
Error modification as follows, for your reference:# include & lt; Stdio. H>
# include & lt; Math. H>
Int sushu (int N);
Int main (int arg c, char * argv [])
{
Int I, N, a;
Scanf_s (" % d ", & amp; N);
For (I=2; I & lt;=N; I++)//output prime
{
A=sushu (I);//a=sushu (N); Z error here
If (a)
Printf (" % d \ n ", I);
}
system("pause");
return 0;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Int sushu (int N)//judgment prime
{
Int a;
If (N & lt; 2)
return 0;
For (a=2; A. & lt;=SQRT (N); +)
{
If (a==0 N %)
return 0;
The else
continue;
}
return 1;
}