作业要求
输入一个固定长度的数组,并输入一个要查找的数,
给出能不能检索到的伪代码并测试。
伪代码
Set first to 0
Set last to length-1
Set found to FALSE
WHILE(first<=last AND NOT found)
Set middle to (first+last)/2
IF(item equals data [middle])
Set found to TURE
ELSE
IF(item < data[middle])
Set last to middle - 1
ELSE
Set first to middle + 1
Return found
测试
用C语言编写了上述程序