int main() { int n; cout << "Enter n" << endl; cin >> n; for (int x = 0; x <= sqrt(n); x++) for (int y = 0; y <= sqrt(n); y++) for (int z = 0; z <= sqrt(n); z++) for (int t = 0; t <= sqrt(n); t++) if (x*x + y*y + z*z + t*t == n) cout << "x=" << x << " y=" << y << " z=" << z << " t=" << t << endl; system("pause"); return 0; }
Answers & Comments
using namespace std;
int main() {
int n;
cout << "Enter n" << endl;
cin >> n;
for (int x = 0; x <= sqrt(n); x++)
for (int y = 0; y <= sqrt(n); y++)
for (int z = 0; z <= sqrt(n); z++)
for (int t = 0; t <= sqrt(n); t++)
if (x*x + y*y + z*z + t*t == n)
cout << "x=" << x << " y=" << y << " z=" << z << " t=" << t << endl; system("pause");
return 0;
}