查找毕达哥拉斯三元组,总和为 1000,没有错误但不运行
Finding pythagorian triplets, with sum 1000, no error but doesnt runs
这是代码
#include <iostream>
#include <cmath>
int main()
{
float c, d;
for(int a = 1; a < 1000; ++a) {
for(int b = 1; b < 1000; ++b) {
c = (a*a) + (b*b);
c = sqrt(c);
d = a + b + c;
if(d==1000) {
std::cout << a << "," << b << "," << c << std::endl;
break;
}
}
}
system("pause");
return 0;
}
无法在我的系统 Dev-C++ 4.9.9.0 上运行它。
但是当在在线编译器中尝试它时,它给出了输出,但具有以下输出:
200,375,425
375,200,425
Disallowed system call: SYS_fork
我想在线
编译器不允许调用
system("pause");
因为这会创建一个新过程。尝试删除该行,看看它是否运行得更好!
在程序结束时暂停的另一种方法是在顶部包含iostream,然后在最后等待输入,然后再返回:
//At the top
#include <iostream>
// Before return 0;
std::cin.get();
相关文章:
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 我的代码中有错误,未声明的标识符
- C++ LeetCode #377 的 DP 解决方案中,此代码是否有错误?
- 试图建立银行管理系统,但有错误
- 我试图创建临时对象的方式有错误吗
- 我的随机生成器是否不工作,或者我决定人/骨架是否击中对手的方式是否有错误
- 我在OpenCV中有错误的"approxPolyDP(ROI_Vertices, ROI_Poly, 1.0, true)"
- 我在这个 C++ 代码上有错误吗?
- 是视觉C++优化器错误还是我的代码中有错误?
- 为什么一个简单的C++程序会有错误的结果?是 #define 引起的吗?
- 对此有错误
- C :数据文件有错误:预期的无限制ID
- 一个带有参数的程序,为什么此程序有错误的答案
- 仅使用boost.datetime在Windows上有错误
- 使用向量循环时,是否有错误
- Microsoft Visual Studio发现我所有的CUDA设备端函数都有错误
- 继承默认构造函数在 gcc 中失败并在 clang 中工作,哪个有错误?
- 为什么有错误未定义_getws_s
- 在快速排序程序中有错误
- C - 检查CIN是否有错误