Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "rus");
- int n;
- cout << "Дано натуральное число N. Указать все тройки x, y, z таких натуральных чисел, что N=x^2+y^2+z^2\n\n";
- cout << "Введите n: ";
- while (!(cin >> n) || (cin.peek() != '\n')) {
- cin.clear();
- while (cin.get() != '\n');
- cout << "Введите n: ";
- }
- for (int x = 0; x < n; x++)
- for (int y = 0; y < n; y++)
- for (int z = 0; z < n; z++)
- if (n == x * x + y * y + z * z)
- cout << "x = " << x << " y = " << y << " z = " << z << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement