MeehoweCK

Untitled

Oct 3rd, 2020
1,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int a, b, x, y;
  7.     cin >> a >> b;
  8.     x = a;
  9.     y = b;
  10.  
  11.     while(a != b)
  12.     {
  13.         if(a > b)
  14.             a = a - b;
  15.         else
  16.             b = b - a;
  17.     }
  18.  
  19.     cout << "NWD liczb " << x << " i " << y << " wynosi " << a << endl;
  20.     cout << "NWW liczb " << x << " i " << y << " wynosi " << x * y / a << endl;
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment