Problems encountered in practice [PTA] output prime number

Record # White strange problem encountered during programming
PAT of the title prime suspect
white The problem is divided into sections,
when the output section primes, as follows:

Here Insert Picture Description

Enter the 20 test, but the result is this:

Here Insert Picture Description

It stands to reason that they should is over 19, but there are some weird numbers
identified the problem as follows:
the array length since by definition have already been determined , so the number = sizeof ... This line is meaningless
solution: the use of n output
final code is:
Here Insert Picture Description
output is correct

Further, it is noted: n is incremented by one in the last cycle, the actual length is greater than 1.

Guess you like

Origin blog.csdn.net/slozer/article/details/88425679