Advertisement
Guest User

Untitled

a guest
Dec 6th, 2020
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include"lib/std_lib_facilities.h"
  2.  
  3. int main(){
  4. vector<double> S {};
  5.  
  6. int towns = 0;
  7. cout << "Skolko gorodow?";
  8. cin >> towns;
  9.  
  10. for(int i = 0;i<towns;i++){
  11. cout << "Vvedite rosstoynie(km)";
  12. double x = 0.0;
  13. cin >> x;
  14. S.push_back(x);
  15. }
  16.  
  17. double sum = 0;
  18.  
  19. for(int i = 0;i<towns;i++){
  20. sum = sum + S[i];
  21. }
  22.  
  23. int what = 0;
  24. cout << "Kakoy gorod(nomer)";
  25. cin >> what;
  26.  
  27. what--;
  28.  
  29. vector<double> x = {};
  30. double sum5 = 0;
  31. double z = 0;
  32. double y = 0;
  33.  
  34. for(double i = -2;i<2;i++){
  35. z = what - i;
  36. y = S[z];
  37. x.push_back(y);
  38. sum5 = S[z];
  39. }
  40.  
  41. sort(x);
  42.  
  43. double naibolshoe = x[0];
  44. double naimenshoe = x[4];
  45.  
  46. double srednie = 0;
  47.  
  48. srednie = sum5 / 5;
  49.  
  50. //output
  51.  
  52. cout << sum << '\n';
  53. cout << naibolshoe << '\n';
  54. cout << naimenshoe << '\n';
  55. cout << srednie << '\n';
  56. }
  57.  
  58.  
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement