Advertisement
MeehoweCK

Untitled

Nov 19th, 2022
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a, b;
  8.     cout << "Podaj dwie liczby naturalne: ";
  9.     cin >> a >> b;
  10.     if(a * b == 0)
  11.     {
  12.         cout << "Liczby te nie maja wspolnego dzielnika.\n";
  13.     }
  14.  
  15.     while(a != b)
  16.     {
  17.         if(a > b)
  18.             a -= b;
  19.         if(b > a)
  20.             b -= a;
  21.     }
  22.     cout << "Najwiekszy wspolny dzielnik tych liczb wynosi " << a << endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement