/*BINARY-SEARCH*/
using namespace std;
int BINARY_SEARCH (int A[], int low, int high, int key){
int mid = ( low + high) / 2;
if( low <= high){
if(key == A[mid])
return mid;
else if(key < A[mid]){
mid = mid - 1;
BINARY_SEARCH(A, low, mid, key);
}
else if(key > A[mid]){
mid = mid + 1;
BINARY_SEARCH(A, mid, high, key);
}
}
else
return 0;
}
int main(){
int A[1000];
int low, high;
int key;
int length;
int i;
scanf("%d",&length);
for(int j = 0; j < length; j++)
scanf("%d",&A[j]);
low = 0;
high = length;
printf("please input key : \n");
scanf("%d",&key);
i = BINARY_SEARCH( A, low, high, key);
if(i != 0)
printf("when i=%d, key = A[i] exist \n",i+1);
else
printf("key is NULL");
}