Facebook
From Dominik Grzegolec, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 130
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int nwd(int a,int b)
  6. {
  7.     int x;
  8.  
  9.     while(b)
  10.     {
  11.         x = b;
  12.         b = a % b;
  13.         a = x;
  14.     }
  15.     return a;
  16. }
  17. int nww(int a,int b)
  18. {
  19.     int nww;
  20.     nww=(a*b)/nwd(a,b);
  21. }
  22.  
  23. int main()
  24. {
  25.  
  26.     int liczba1;
  27.     int liczba2;
  28.     cout<<"podaj pierwsza liczbe: ";
  29.     cin>>liczba1;
  30.     cout<<"podaj druga liczbe: ";
  31.     cin>>liczba2;
  32.     nww(liczba1,liczba2);
  33.     cout<<"NWD = "<<nwd(liczba1,liczba2)<<endl;
  34.     cout<<"NWW = "<<nww(liczba1,liczba2)<<endl;
  35.     return 0;
  36. }
  37.