Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include"lib/std_lib_facilities.h"
- int main(){
- vector<double> S {};
- int towns = 0;
- cout << "Skolko gorodow?";
- cin >> towns;
- for(int i = 0;i<towns;i++){
- cout << "Vvedite rosstoynie(km)";
- double x = 0.0;
- cin >> x;
- S.push_back(x);
- }
- double sum = 0;
- for(int i = 0;i<towns;i++){
- sum = sum + S[i];
- }
- int what = 0;
- cout << "Kakoy gorod(nomer)";
- cin >> what;
- what--;
- vector<double> x = {};
- double sum5 = 0;
- double z = 0;
- double y = 0;
- for(double i = -2;i<2;i++){
- z = what - i;
- y = S[z];
- x.push_back(y);
- sum5 = S[z];
- }
- sort(x);
- double naibolshoe = x[0];
- double naimenshoe = x[4];
- double srednie = 0;
- srednie = sum5 / 5;
- //output
- cout << sum << '\n';
- cout << naibolshoe << '\n';
- cout << naimenshoe << '\n';
- cout << srednie << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement