Facebook
From Wojtek legieta kl.1P, 4 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 224
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int nwd(int x, int y)
  6. {
  7.     if (y==0) {
  8.             cout << "Liczba y nie może równać się 0";
  9.     }
  10.     else if (x%y==0) return y;
  11.     else return nwd(y,x%y);
  12. }
  13.  
  14. int main()
  15. {
  16.     int Nr1,Nr2;
  17.     cout << "Program liczy NWD dwóch podanych cyfr x oraz y" << endl;
  18.     cout << "Podaj x:";
  19.     cin >> Nr1;
  20.     cout << "Podaj y:";
  21.     cin >> Nr2;
  22.     if (nwd(Nr1,Nr2)!=0)
  23.     {
  24.         cout << "Nwd wynsoi podanych liczb wynosi:"<< nwd(Nr1,Nr2) << endl;
  25.     }
  26.  
  27. }
  28.  

Replies to Zad.8 rss

Title Name Language When
Zad.8 Wojtek legieta kl.1P cpp 4 Years ago.