Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <numeric>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- cout << "n = "; cin >> n;
- vector <int> a;
- for (int i = 0; i < n; ++i)
- {
- int x; cin >> x;
- a.push_back(x);
- }
- vector <int> :: iterator itmin = min_element(a.begin(), a.end());
- vector <int> :: iterator itmax = max_element(a.begin(), a.end());
- if (itmax > itmin) cout << "Максимальный элемент встречается позже минимального\n";
- else cout << "s = " << accumulate(itmax + 1, itmin, 0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement