Advertisement
Guest User

00000000000

a guest
Mar 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1.  
  2. #include<iostream>
  3.  
  4. using namespace std;
  5.  
  6. int max(int a[100], int i, int j)
  7. {
  8. if(i==j) return a[i];
  9. else { int m=(i+j)/2;
  10. int m1=max(a,i,m);
  11. int m2=max(a,m+1,j);
  12. if(m1<m2) return m2;
  13. else return m1;
  14. }
  15. }
  16.  
  17. void citire(int a[100], int n)
  18. {
  19. if(n>0) { citire(a,n-1);
  20. cin>>a[n];
  21. }
  22. }
  23.  
  24. void afis(int a[100],int n)
  25. {
  26. if(n>0) { afis(a,n-1);
  27. cout<<a[n]<<" ";
  28. }
  29. }
  30.  
  31. int main()
  32. {
  33. int n,a[100];
  34. cin>>n;
  35. citire(a,n);
  36. afis(a,n);
  37. cout<<endl;
  38. cout<<max(a,1,n);
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement