Advertisement
Dizzy3113

Untitled

Jan 15th, 2020
106
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 n;
  5. float t[101];
  6. float maxim(int s, int d)
  7. {
  8. if(s==d)
  9. return t[s];
  10. if(s<d)
  11. {
  12. int m=(s+d)/2;
  13. float max1, max2;
  14. max1 = maxim(s,m);
  15. max2 = maxim(m+1, d);
  16. if(max1<max2)
  17. return max2;
  18. return max1;
  19. }
  20.  
  21. }
  22. int main()
  23. {
  24. cin>>n;
  25. for(int i=1; i<=n; i++)
  26. cin>>t[i];
  27.  
  28. cout<<maxim(1, n);
  29.  
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement