Advertisement
catalyn

pozitive divide et imp

Oct 15th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int par(int v[100],int s,int d)
  5. {int mij,m1,m2;
  6.  
  7. if(s==d)
  8. {
  9. if(v[s]>=0)
  10. return 1;
  11. else
  12. return -1;
  13. }
  14. else
  15. {
  16. mij=(s+d)/2;
  17.  
  18. return par(v,s,mij)+par(v,mij+1,d);
  19.  
  20. }
  21. }
  22. int main()
  23. {
  24. int v[100],i,n;
  25. cin>>n;
  26. for(i=1;i<=n;i++)
  27. cin>>v[i];
  28. if(par(v,1,n)==n)
  29. cout<<"da";
  30. else
  31. cout<<"nu";
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement