Sam*_*Sam 15 c++ eclipse gcc codeblocks
我写了下面的c++程序CodeBlocks,结果是9183.我再次写入Eclipse和运行后,它返回9220.两者都使用MinGW.正确的结果是9183.这段代码出了什么问题?谢谢.源代码:
#include <iostream>
#include <set>
#include <cmath>
int main()
{
using namespace std;
set<double> set_1;
for(int a = 2; a <= 100; a++)
{
for(int b = 2; b <= 100; b++)
{
set_1.insert(pow(double(a), b));
}
}
cout << set_1.size();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
Jus*_*ᚄᚒᚔ 12
您可能会看到由于CodeBlocks在32位模式下编译和Eclipse编译在64位模式下导致的精度错误:
$ g++ -m32 test.cpp
$ ./a.out
9183
$ g++ -m64 test.cpp
$ ./a.out
9220
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
505 次 |
| 最近记录: |