Advertisement
wiktormadera

zad17

Apr 2nd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int NWD(int a, int b)
  6. {
  7. int c,d;
  8.     if(a>b)
  9.     {
  10.         c=a;
  11.         a=b;
  12.         b=c;
  13.     }
  14.     for(int i=1;i<=b;i++)
  15.    
  16.         {
  17.             d=i;
  18.         }
  19.     return d;
  20. }
  21.  
  22. int main()
  23. {
  24.     int a,b;
  25.     cout << "Najwiekszy wspolny dzielnik. Podaj liczbe naturalna a:" << endl;
  26.     cin >> a;
  27.     cout << "Podaj liczbe naturalna b:" << endl;
  28.     cin >> b;
  29.     cout << NWD(a,b);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement