Advertisement
Guest User

Untitled

a guest
May 24th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int n , a[1000],s,p=-1, u=-1;
  4. int main()
  5. {
  6.      cin>>n;
  7.      for(int i=1;i<=n;i++)
  8.            cin>>a[i];
  9.     for(int i=1;i<=n;i++)
  10.      {
  11.            if(a[i]%2==0)
  12.                 p=a[i];
  13.                u=a[i];
  14.               break;
  15.           
  16.      }
  17.      for(int i=p;i<=n;i++)
  18.          {
  19.              if(a[i]%2==0)
  20.              u=a[i];
  21.          }
  22.          
  23.      if(p==-1)
  24.         cout<<"Nu exista";
  25.     else
  26.        for(int i=p;i<=u;i++)
  27.            s=s+a[i];
  28.        cout<<s;
  29.      return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement