#include<stdio.h>
int locate(int A[],int s,int n,int x) {
   if( n==1 )
     if( A[s]==x ) return s;
     else return -1;
   int j,k,m = n/2;
   j = locate(A,s,m,x);
   k = locate(A,s+m,n-m,x);
   return j>=0 ? j : k;
}

#define N 8
int main() {
   int i, A[N];
   for( i=0; i<N; i++ ) A[i] = i;
   i = locate(A,0,N,6);
   printf("i=%d A[i]=%d\n",i,A[i]);
   return 1;
}
