SHARE
TWEET

Untitled

a guest Feb 27th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int v[1001];
  6.  
  7.  
  8. int maxim(int st, int dr)
  9. {
  10.     int m1,m2,mij;
  11.     if(st==dr) return v[st];
  12.     else{mij=(st+dr)/2;
  13.     m1=maxim(st,mij);
  14.     m2=maxim(mij+1,dr);
  15.     if(m1>m2) return m1;
  16.     else return m2;}
  17.  
  18. }
  19.  
  20. int main()
  21. {
  22. int n,i;
  23. cin>>n;
  24. for(i=1; i<=n; i++)
  25.     cin>>v[i];
  26. int M;
  27.    M=maxim(1,n);
  28.    cout<<M<<endl;
  29.  
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top