Statis

Ex 4

Nov 13th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int v[100];
  4. void citire (int n)
  5. {
  6. for (int i=1;i<n+1;i++)
  7. cin>>v[i];
  8. }
  9. int f (int s, int d)
  10. {
  11. if (s==d)
  12. {
  13. if(v[s]%2==0)
  14. return 1;
  15. else return 0;
  16. }
  17. else {
  18. int m=(s+d)/2;
  19. return f(s, m)+f(m+1, d);
  20. }
  21. }
  22. int main()
  23. {
  24. int n;
  25. cin>>n;
  26. citire(n);
  27. cout<<f(1, n);
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment