SHARE
TWEET

Untitled

a guest May 20th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  #include <bits/stdc++.h>
  3. using namespace std;
  4. int a[100], n,j, i;
  5.  
  6. int minn(int i, int j){
  7.     int k,d, minim;
  8.     if (i==j) minim=a[i];
  9.        else { k=min(a[i], a[(i+j)/2]);
  10.               d=min(a[(i+j)/2+1],a[j]);
  11.               minim=min(k,d);
  12.        }
  13.  return minim;
  14. }
  15.  
  16. int main(){
  17.     cin>>n;
  18.     for(i=1; i<=n; i++) cin>>a[i];
  19.     cout<<"min= "<< minn(1,n)<<endl;
  20.     return 0;
  21. }
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