我自己编写递归二叉查找问题,有警告如下,请帮忙找出错误谢谢
--------------------Configuration: banerysearch - Win32 Debug--------------------
Compiling...
banerysearch.cpp
D:\课程\编程学习\C++文件夹\作业\fileshiyan\banerysearch.cpp(22) : warning C4715: 'binerysearch' : not all control paths return a value
banerysearch.obj - 0 error(s), 0 warning(s)
程序如下:
#include<iostream.h>
#include<stdlib.h>
typedef char datatype;
int binerysearch(datatype a[],datatype goal,int low,int hight)
{
int mid=(low+hight)/2;
datatype midvalue=a[mid];
if(midvalue==goal) return mid;
else if(goal<midvalue&&low!=hight)
binerysearch(a,goal,low,mid-1);
else if(goal>midvalue&&low!=hight)
binerysearch(a,goal,mid+1,hight);
else
{
cout<<"No that number!!"<<endl;
return -1;
}
}
void main()
{
int i;
char a[6]={'a','b','c','d','e','f'};
i=binerysearch(a,'c',0,5);
cout<<i<<endl;
}