Facebook
From Wojtek Leg 1, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 126
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int nwd(int w, int t)
  6. {
  7.     if (w%t==0){
  8.         return t;
  9.     }
  10.     else nwd(t,w%t);
  11. }
  12. int nww(int w, int t)
  13. {
  14.     return (w*t)/nwd(w,t);
  15. }
  16.  
  17. int main()
  18. {
  19.    int q;
  20.    int e;
  21.    cout<<"Podaj liczbe a: ";
  22.        cin>>q;
  23.        cout<<"Podaj liczbe b: ";
  24.    cin>>e;
  25.     while(e==0)
  26.     {
  27.  
  28.    if(q==0)
  29.    {
  30.        cout<<"Liczba b nie mo¿e byæ rowna 0"<<endl;
  31.  
  32.    }
  33.     }
  34. cout<<"NWW liczb wynosi:"<< q  << "oraz:" << e <<":"<<"wynosi:" << nww(q,e) << endl;
  35.  
  36.  
  37. }
  38.