Advertisement
LukaszPanko

Zadanie 17

Mar 29th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int NWD(int l1, int l2)
  7. {
  8.        do
  9.     {
  10.         if(l1 > l2) {
  11.            l1=l1-l2;
  12.         } else {
  13.             l2=l2-l1;
  14.         }
  15.     }
  16.     while(l1 != l2);
  17.     cout << l1;
  18.     return 0;
  19. }
  20.  
  21. int main()
  22. {
  23.     int liczba1;
  24.     int liczba2;
  25.     cout << "Podaj pierwsza liczbe: " ;
  26.     cin >> liczba1;
  27.     cout << "Podaj druga liczbe: " ;
  28.     cin >> liczba2;
  29.     cout<<"Najwiekszy wspolny dzielnik podanych liczb to: ";
  30.     NWD(liczba1,liczba2);
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement