Here’s the code
#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;
}
Cannot run it on my system Dev-C++ 4.9.9.0.
But when tried it in an online compiler and it gave the output but with the following output:
200,375,425
375,200,425
Disallowed system call: SYS_fork
I’d imagine that the online compiler disallows calling
since that creates a new process. Try removing that line and see if it runs better!
Another way of pausing at the end of the program would be to include iostream at the top, and then wait for input at the end, before returning: