// 编写一个程序,输出在顺序表(1,2, 3, 4, 5, 6, 7, 8, 9, 10)中采用折半查找方法查找关键字9的过程。 #include #include using namespace std; template int BinarySearch(vector l, T value, int left, int right) { if (left > right) { return -1; // 未找到目标值 } int mid = left + (right - left) / 2; // 计算中间位置 cout << "正在查找第"< int BinarySearch(vector l, T value) { return BinarySearch(l,value, 0, l.size() - 1); } int main() { vector l = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int index=BinarySearch(l, 9); cout<