-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
#include
int itop,ibottom,iresearch,imiddle; int iA[N]={0,1,2,3,4,5,6,7,8}; scanf(\ itop=0;
ibottom=N-1;
while(itop<=ibottom) {
imiddle=(itop+ibottom)/2 ; if(iresearch ibottom=imiddle-1; else if (iresearch>iA[imiddle]) itop=imiddle+1; else{ printf(\元素%d在数组中, 下标是%d\\n, iresearch,imiddle\ return; } } ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- printf(\在数组中未找到\\n\ } -------------------------------------------------------------------------------