Advertisement
Guest User

maxim

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