daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int sumpare(int p,int u, int v[1001])
  4. {
  5.     int mij,s1,s2;
  6.     if(p!=u)
  7.     {
  8.         mij=(p+u)/2;
  9.         s1=sumpare(p,mij,v);
  10.         s2=sumpare(mij+1,u,v);
  11.             return s1+s2;
  12.     } else if(v[p]%2==0)
  13.         return v[p];
  14.         else return 0;
  15.         }
  16. int main()
  17. {
  18.     int v[1001],n,i,s;
  19.     cin>>n;
  20.     for(i=1;i<=n;i++)
  21.         cin>>v[i];
  22.     s=sumpare(1,n,v);
  23.     cout<<s;
  24.     return 0;
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top