MeehoweCK

Untitled

Mar 30th, 2020
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. // ALGORYTM EUKLIDESA
  6.  
  7. int main ()
  8. {
  9.     int a, b, x, y;
  10.     cout << "Podaj dwie liczby calkowite: ";
  11.     cin >> x >> y;
  12.     a = x;
  13.     b = y;
  14.  
  15.     while(a != b)
  16.     {
  17.         if(a > b)
  18.             a = a - b;      // a -= b;
  19.         if(b > a)
  20.             b = b - a;
  21.     }
  22.  
  23.     cout << "Najwiekszym wspolnym dzielnikiem liczb " << x << " i " << y << " jest liczba " << a << endl;
  24.     cout << "Najmniejsza wspolna wielokrotnoscia liczb " << x << " i " << y << " jest liczba " << x * y / a << endl;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment