# Include
Int bin_search (int key [], int low, int high, int k) {int mid; if (low> high) return-1; else {mid = (low + high) /2; if (key [mid] = k) return mid; if (k> key [mid]) return bin_search (key, mid + 1, high, k ); /* search for the second half of the sequence */else return bin_search (key, low, mid-1, k ); /* search for the first half of the sequence */} int main () {int n, I, addr; int A [10] =, 19,21}; printf ("The contents of the Array A [10] are \ n"); for (I = 0; I <10 ; I ++) printf ("% d", A [I]); /* display the content in array A */printf ("\ nPlease input a interger for search \ n"); scanf ("% d", & n ); /* enter the element to be searched */addr = bin_search (A, n); if (-1! = Addr)/* search successful */printf ("% d is at the % dth unit is array A \ n", n, addr); else
Printf ("There is no % d in array A \ n", n);/* search failed */getchar (); return 0 ;}