Advertisement
aimon1337

numere pare

Jan 29th, 2020
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int a[100],n;
  4. int pare(int st, int dr)
  5. {
  6.     int p1,p2,mij=(st+dr)/2;
  7.     if(st==dr)
  8.         if(a[st]%2==0)
  9.         return 1;
  10.         else return 0;
  11.     else
  12.     {
  13.         p1=pare(st,mij);
  14.         p2=pare(mij+1,dr);
  15.         return p1+p2;
  16.     }
  17. }
  18. int main()
  19. {
  20. int i;
  21. cin>>n;
  22. for(i=1;i<=n;i++) cin>>a[i];
  23. cout<<pare(1,n);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement