#include
using namespace std;
#define MAXSIZE 20
typedef struct{
int key;
char *otherinfo;
}ElemType;
typedef struct{
ElemType *r;
int length;
}SqList;
//筛选法调整堆
void HeapAdjust(SqList &L,int s,int m){
ElemType rc;
int j;
rc=L.r[s];
for(j=2*s;j<=m;j*=2){
if(j=L.r[j].key) break;
L.r[s]=L.r[j]; s=j;
}
L.r[s]=rc;
}
void Create_Sq(SqList &L){
int i,n;
cout<<"数据个数:";
cin>>n;
cout<<"待排序的数据:";
for(i=1;i<=n;i++){
cin>>L.r[i].key;
L.length++;
}
}
//建初堆
void CreatHeap(SqList &L){
int i,n;
n=L.length;
for(i=n/2;i>0;--i)
HeapAdjust(L,i,n);
}
//堆排序
void HeapSort(SqList &L){
int i;
ElemType x;
CreatHeap(L);
for(i=L.length;i>1;--i){
x=L.r[1];
L.r[1]=L.r[i];
L.r[i]=x;
HeapAdjust(L,1,i-1);
}
}
void show(SqList L){
int i;
for(i=1;i<=L.length;i++)
cout<
