# Python 语言程序设计（2017 年秋）

1062. 递归实现二分查找

//********** Specification of binarySearch **********
int binarySearch (int a[],int L,int R,int x);
/* PreCondition:
a is an integer array in ascending order, x is the value to be found
L and R are lower and upper bounds to be searched
PostCondition:
return position of an element of a that has value x, -1 if not found
*/


#include<stdio.h>

#define N 1024

int binarySearch (int a[],int L,int R,int x)
/* PreCondition:
a is an integer array in ascending order, x is the value to be found
L and R are lower and upper bounds to be searched
PostCondition:
return position of an element of a that has value x, -1 if not found
*/
{ //TODO: your function definition
}

int main()
{   int n,i,a[N+1],x;
scanf("%d",&n);
for (i=0;i<n;i++) scanf("%d",&a[i]);
scanf("%d",&x);

//********** binarySearch is called here ***********
printf("%d\n",binarySearch(a,0,n-1,x));
//*********************************************
return 0;
}


### 样例

Input
7
1 3 5 7 53 355 3432
3

Output
1