Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main ()
- {
- int n;
- cin >> n;
- int a,b,s=0;
- cin >> a >> b;
- int c;
- for (int i = 3 ; i <= n; ++i)
- {
- cin >> c;
- if (a<b && b>c)
- s+=b;
- a=b;
- b=c;
- }
- cout << s;
- }
Advertisement
Add Comment
Please, Sign In to add comment