Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <climits>
- using namespace std;
- int main()
- {
- int a[1000], n, S= 0 , x = 0, y = 0 ;
- cin >> n ;
- for ( int i = 0 ; i < n ; i ++ )
- cin >> a[i] ;
- for ( int i =0 ; i <n ; i ++ )
- {
- if ( a [i ]% 2 ==0 )
- {
- x= i;
- break ;
- }
- }
- for ( int i = n ; i >= 0 ; i -- )
- {
- if ( a[i]% 2 == 0 )
- {
- y = i;
- break ;
- }
- }
- for ( int i = x ; i <= y ; i ++ )
- {
- S+= a[i];
- }
- cout << S ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement