SHARE
TWEET

Untitled

a guest Nov 17th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int trazi (int a[], int i, int j){
  2.  
  3.     if (i>j) return -1;
  4.     int p,k,s,pocetni ;
  5.     p=i; k=j; pocetni=i;
  6.     while(p<=k){
  7.  
  8.         s=(p+k)/2;
  9.         if(a[s]==a[pocetni]) return s-pocetni;
  10.         if(a[s] > a[pocetni] ) p = s+1;
  11.         if(a[s] < a[pocetni] ){
  12.  
  13.             if(s-1!=0 && a[s-1]<a[s]) {k=s-1;}
  14.             else if (s-1!=0 && a[s-1]>a[s]) {return s-pocetni;
  15.             }
  16.         }
  17.     }
  18.     return 0;
  19. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top