SHARE
TWEET

Untitled

a guest Feb 27th, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int v[1001];
  6.  
  7. int suma(int st, int dr){
  8. int s1,s2,mij;
  9. if(st==dr){if(v[st]%2==0) return v[st];
  10. else return 0;}
  11.  
  12. else{mij=(st+dr)/2;
  13.      s1=suma(st,mij);
  14.      s2=suma(mij+1,dr);
  15.     return s1+s2;
  16.     }
  17.  
  18. }
  19.  
  20. int main()
  21. {
  22. int n,i;
  23. cin>>n;
  24. for(i=1; i<=n; i++)
  25.     cin>>v[i];
  26. cout<<suma(1,n);
  27.  
  28.  
  29. }
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