Advertisement
rikardoricz

15 IF Tomasz Świątek 3BTI/2

Nov 17th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     float a,b,c,d,e,sr,mx,mn; //sr - srednia; mx - wartosc max; mn - wartosc min
  8.  
  9.     cout << "Podaj 5 liczb oddzielonych spacja albo enterem:" << endl;
  10.     cin >>a>>b>>c>>d>>e;
  11.  
  12.     sr=(a+b+c+d+e)/5;
  13.  
  14.     mx=a;
  15.  
  16.     if (b>mx)
  17.     {
  18.         mx=b;
  19.     }
  20.     if (c>mx)
  21.     {
  22.         mx=c;
  23.     }
  24.     if (d>mx)
  25.     {
  26.         mx=d;
  27.     }
  28.     if (e>mx)
  29.     {
  30.         mx=e;
  31.     }
  32.  
  33.     mn=a;
  34.  
  35.     if (mn>b)
  36.     {
  37.         mn=b;
  38.     }
  39.     if (mn>c)
  40.     {
  41.         mn=c;
  42.     }
  43.     if (mn>d)
  44.     {
  45.         mn=d;
  46.     }
  47.     if (mn>e)
  48.     {
  49.         mn=e;
  50.     }
  51.  
  52.     cout << "Najwieksza liczba to: " << mx << endl;
  53.     cout << "Najmniejsza liczba to: " << mn << endl;
  54.     cout << "Srednia z podanych liczb wynosi: " << sr << endl;
  55.  
  56.     return 0;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement