Advertisement
Statis

Ex 5

Nov 13th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 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]<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. int x=f(1,n);
  28. if (x==n)
  29. cout<<"doar negative";
  30. else {
  31. if (x==0)
  32. cout<<"doar pozitive";
  33. else cout<<"pozitive si negative";
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement