JakubJaneczek

Zadanie 18

Apr 7th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int a,b,c;
  4.  
  5. int nww(int a, int b)
  6. {
  7.     int w=a+b;
  8.     while(a%w!=0 || b%w!=0)
  9.     {
  10.         w=w-1;
  11.     }
  12.     w=a*b/w;
  13.     return w;
  14. }
  15.  
  16. int main()
  17. {
  18.     cout << "Podaj 2 liczby" << endl;
  19.     cin >> a;
  20.     cin >> b;
  21.     cout << nww(a,b);
  22.     cout << endl;
  23.     cout << "Dla liczb 5,15" << endl;
  24.     cout << nww(5,15);
  25.     cout << endl;
  26.     cout << "Dla liczb 7,49" << endl;
  27.     cout << nww(7,49);
  28.  
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment