Advertisement
PiotrSzewczyk

Zad 13

Mar 31st, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int max (int a, int b, int c)
  5. {
  6.    if (a<0 || b<0 || c<0){
  7.     cout<<"Podaj liczby NATURALNE"<<endl;
  8.    }
  9.     else {
  10.         if (a>b){
  11.             if (a>c){
  12.             return a;
  13.             }
  14.             else {
  15.             return c;
  16.             }
  17.         }
  18.         else {
  19.             if (b>c){
  20.             return b;
  21.             }
  22.             else {
  23.             return c;
  24.             }
  25.         }
  26.     }
  27. }
  28.  
  29. int main ()
  30. {
  31.     int a, b, c;
  32.     cout<<"Podaj liczby naturalne"<<endl;
  33.     cin>>a>>b>>c;
  34.     cout<<"Najwieksza liczba z podanych to: "<<max(a,b,c)<<endl;
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement