According to:
Jobs failing on Windows with Exit Code 0xC000013A
Globally speaking, Exit Code 0xC000013A means that the application terminated as a result of a CTRL+C or? closing command prompt window
I copied, compiled and ran your code. With x=9
, the code is stuck in the while
loop forever, so I had to close the program using the close button ([x] button in the upper right corner). That generated the 0xc000013a error code. (With x=7
the program is not stuck in the while
loop so it is able to exit normally.)
More specifically, for x=9
the program is stuck in the while
loop because when i=3
then (x % i) == 0
(9 mod 3 = 0) and the statement i = i + 1
never executes. So i
never increments beyond 3 and i < x
(3 < 9) is always true.
So the immediate problem is that your code never exits (for x=9
) and you have to stop it, presumably by clicking the close button. But the larger issue is that your logic is bad and your program isn't working the way you think it is.
For example, when x=9
and i=2
, then (x % i) != 0
and that leads to b = b + 1
. That means b > 0
and your program should return 1, which you indicated meant prime in the case of x=7
. But 9 is not prime.
Also, isPrime
has a return type of bool
but you are returning int
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…