Advertisement
STANAANDREY

sesiune spec bac2022

May 31st, 2022
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void patrate(int n, int &x, int &y) {
  5.     bool ok = false;
  6.     for (x = 2; x < n; x++) {
  7.         for (y = x + 1; y <= n; y++) {
  8.             if (x * x * y * y == n) {
  9.                 ok = true;
  10.                 break;
  11.             }
  12.         }
  13.         if (ok) {
  14.             break;
  15.         }
  16.     }
  17.     if (!ok)
  18.         x = y = 0;
  19. }
  20.  
  21. int main() {
  22.     int x = 1, y = 1;
  23.     patrate(400, x, y);
  24.     cout << x << ' ' << y << endl;//2 10
  25.     return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement