Advertisement
MeehoweCK

Untitled

Jun 17th, 2022
1,087
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 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.  
  11.     while(a != b)       // != - różnią się od siebie
  12.     {
  13.         if(a > b)
  14.             a -= b;
  15.         if(b > a)
  16.             b -= a;
  17.     }
  18.  
  19.     cout << "Najwiekszy wspolny dzielnik dwoch podanych liczb wynosi " << a << endl;
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement