Advertisement
wiktormadera

zad13

Apr 2nd, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int MAX (int n1, int n2, int n3)
  6. {
  7.     if(n1>=n2&&n1>=n3)
  8.     {
  9.         return n1;
  10.     }
  11.     else if(n2>=n1&&n2>=n3)
  12.     {
  13.         return n2;
  14.     }
  15.     else if(n3>=n2&&n3>=n1)
  16.     {
  17.         return n3;
  18.     }
  19. }
  20.  
  21. int main()
  22. {
  23.     int n1,n2,n3;
  24.     cout << "Podaj pierwsza liczbe naturalna: " << endl;
  25.     cin >> n1;
  26.     cout << "Podaj druga liczbe naturalna: " << endl;
  27.     cin >> n2;
  28.     cout << "Podaj trzecia liczbe naturalna: " << endl;
  29.     cin >> n3;
  30.     if(n1>=1&&n2>=1&&n3>=1)
  31.     {
  32.         cout << "Najwieksza liczba: " << MAX(n1,n2,n3);
  33.     }
  34.     else
  35.     {
  36.         cout << "Ktoras z podanych liczb nie jest naturalna.";
  37.     }
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement