新手求问一个折半查找的有关问题

新手求问一个折半查找的问题
#include <iostream>
#include <string>

using namespace std;

int BinaryS(int *source,int dest,int number); //折半查找

int main()
{
int s[12] = {1,2,3,4,5,6,7,8,9,10,11,12};

//int num = BinaryS(s,22,12);

cout << "数字11在哪个位置呢?\n";
cout << BinaryS(s,11,12) << endl;

return 0;
}
int BinaryS(int *source,int dest,int number)
{
int left = 0;
int right = number - 1;
while(left <= right)
{
int middle = (right - left)/2;
if( dest < source[middle])
right = middle - 1;
else if (dest > source[middle])
left = middle + 1;
else
//if( dest == source[middle])
return middle;

}

return -1;
}


根据我写的代码,如果用前半段的数字测试,一切正常,如果用后半段的数字测试,就无法显示了,好像就陷在while里面出不来了,弄不明白!
------解决方案--------------------
int middle = (right + left)/2;
------解决方案--------------------
同一楼!middle的赋值语句右边应该是左加右除以2