Advertisement
Solingen

z8.2.cpp

Dec 22nd, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool isPythagorean(int a, int b, int c)
  5. {
  6.     return (a*a + b*b == c*c);
  7. }
  8.  
  9. int main()
  10. {
  11.     int limit;
  12.     cout << "Введите верхний предел: ";
  13.     cin >> limit;
  14.    
  15.     int count = 0;
  16.     for (int a = 1; a <= limit; a++)
  17.     {
  18.         for (int b = a; b <= limit; b++)
  19.         {
  20.             for (int c = b; c <= limit; c++)
  21.             {
  22.                 if (isPythagorean(a, b, c))
  23.                 {
  24.                     count++;
  25.                     cout << count << ") " << a << "," << b << "," << c << "\n";
  26.                 }
  27.             }
  28.         }
  29.     }
  30.  
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement