<pre name="code" class="cpp">#include <iostream>
using namespace std;
const int maxn = 100;
void heap_sort(int arr[],int &len);
void heap_down_adjust(int arr[],int i,int &len);
int bin_search(int arr[],const int &len,const int &k);
int bin_search2(int arr[],const int &len,const int &k);
void my_swap2(int &a,int &b)
{
int tmp;
tmp = a;
a = b;
b = tmp;
}
void my_swap(int &a, int &b)
{
a = a ^ b;
b = a ^ b;
a = a ^ b;
}
int main()
{
int arr[maxn];
int tmp,len;
len = 0;
cout << "请输入一个序列(-1结束)" << endl;
while(cin >> tmp)
{
if(tmp == -1)
bre
//二分查找的改进,是把原来的mid的计算进行了优化,而非中位数形式;思想是根据所查找的数与low high的所对应的数的比率改进的二分查找的函数:基本思想是,充分利用关键字本身的信息,用关键字和low high所对应的值的比率来确定mid,即每次排除的数据量会充分依赖关键字的大小,这比普通的二分查找效率高一些。#include using namespace std;const int maxn = 100;void heap_sort(int arr[],int &len);void hea