Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int suma = 0;
  7. int max;
  8. int min;
  9. double srednia = 0;
  10. int ilosc_liczb = 0;
  11. int liczba = 0;
  12.  
  13.  
  14. cout << "Ile liczb chcesz wprowadzic?" << endl;
  15. cin >> ilosc_liczb;
  16.  
  17.  
  18. for( int i = 0; i < ilosc_liczb; i++ )
  19. {
  20. min = liczba;
  21. max = liczba;
  22. cin >> liczba;
  23. suma += liczba;
  24.  
  25. if( liczba < min )
  26. {
  27. min = liczba;
  28. }
  29.  
  30. else if( liczba > max )
  31. {
  32. max = liczba;
  33. }
  34. }
  35.  
  36. srednia = suma / ilosc_liczb;
  37.  
  38. cout << "Najmniejsza liczba wynosi: " << min << endl;
  39. cout << "Najwieksza liczba wynosi: " << max << endl;
  40. cout << "Srednia arytmetyczna podanych liczb wynosi: " << srednia << endl;
  41.  
  42. system( "PAUSE" );
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement