Home > Back-end >  Help bosses
Help bosses

Time:10-30

7-2 shows the specified range of prime Numbers and sum (20 points)
Subject requirements according to the given integers M and N interval prime Numbers and sum,

Input format:
In the line of the input of two positive integers M and N (1 M or less or less N 1000) or less,

The output format:
According to specified range of prime Numbers, prime Numbers between empty one, every 5 in a row, a single line of output of prime Numbers and prime Numbers and,

Input the sample:
Given a set of input here, for example:

4 30
The output sample:
Here is given the corresponding output, for example:

5 July 11 of 13 17
19 and 29
8 sum amount==124

The answer is always wrong


This is my code:
#include
#include
Int ss (int x) {
Int f=1;
For (int I=2; i{if (x % I==0)
F=0; }

return f;
}
Int main ()
{
Int M, N, count=0, sum=0;
The scanf (" % d % d ", & amp; M, & amp; N);
If (M>=1 & amp; & M<=N& & N
=1000){
For (int j=M; J<=N; J++)
{if (ss (j)==1)
{count++;
If (count 5==% 1 & amp; & Count> 1)
printf("\n");
Printf (" % d ", j);
The sum +=j;

}
}
Printf (" \ namount sum==% d % d ", count, sum);
}
else return 0;
}

  • Related