我一直在尝试创建自己的主要检查功能,虽然奇怪的是当我调用isPrime(7)它返回1时,这很好,但是当我调用isPrime(9)时它会给我以下错误:
'Mathematics.exe':已加载'C:\ Documents and Settings\mbryant\My Documents\Visual Studio 2010\Projects\Mathematics\Debug\Mathematics.exe',已加载符号.'Mathematics.exe':加载'C:\ WINDOWS\system32 \ntdll.dll',找不到或打开PDB文件'Mathematics.exe':加载'C:\ WINDOWS\system32\kernel32.dll',找不到或者打开PDB文件'Mathematics.exe':加载'C:\ WINDOWS\system32\msvcp100d.dll',加载符号.'Mathematics.exe':已加载'C:\ WINDOWS\system32\msvcr100d.dll',已加载符号.线程'Win32 Thread'(0x6ec)已退出,代码为-1073741510(0xc000013a).
这是代码:
#include <iostream>
using namespace std;
bool isPrime(int x){
int b = 0;
int i = 2;
if(x == 2){
return 1;
}
if (x > 2){
while(i < x){
if ( (x % i) != 0){
b = b + 1;
i = i + 1;
}
}
if (b > 0){
return 1;
} if (b == 0){
return 0;
}
} …Run Code Online (Sandbox Code Playgroud)