Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <iomanip>
- #include <vector>
- #include <cmath>
- using namespace std;
- int main()
- {
- cout << setprecision(3);
- cout << fixed;
- int n;
- cin >> n;
- vector <double> a;
- int j;
- for (int i = 0; i < n; i++) {
- cin >> j;
- a.push_back(j);
- }
- int left = 0;
- int right = 0;
- int schet = 0;
- for (int i = 0; i < n; i++) {
- if (a[i] == 0) {
- left = i;
- schet++;
- break;
- }
- }
- for (int i = n; i > 0; i--) {
- if (a[i] == 0) {
- right = i;
- schet++;
- break;
- }
- }
- if (schet < 2) {
- cout << "0" << endl;
- }
- double ans = 0;
- for (int i = a[left] + 1; i < a[right]; i++) {
- ans+=a[i];
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement