Advertisement
wiktormadera

zad18

Apr 2nd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 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.     return d;
  16. }
  17. int NWW(int a, int b, int d)
  18. {
  19.     int iloczyn,NWW;
  20.     iloczyn = a*b;
  21.     NWW=iloczyn/d;
  22.     return NWW;
  23. }
  24.  
  25. int main()
  26. {
  27.     int a,b,d;
  28.     cout << "Najmneijsza wspolna wielokrotnosc. Podaj liczbe naturalna a:" << endl;
  29.     cin >> a;
  30.     cout << "Podaj liczbe naturalna b:" << endl;
  31.     cin >> b;
  32.     d=NWD(a,b);
  33.     cout << NWW(a,b,d);
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement