问题处在哪了?
#include<stdio.h>int N;
struct Sqlist{
int Heap[100];
};
void InitSqList(struct Sqlist H) {
int i;
scanf("%d",&N);
for(i=1;i<=N;i++)
scanf("%d",&H.Heap[i]);
}
void HeapSort(struct Sqlist H) {
int i,m;
for(i=N/2;i>0;--i)
HeapAdjust(H,i,N);
for(i=N;i>1;--i) {
m=H.Heap[1];
H.Heap[1]=H.Heap[i];
H.Heap[i]=m;
HeapAdjust(H,1,i-1);
}
}
HeapAjust(struct Sqlist H, int s, int m) {
int c,j;
c=H.Heap[s];
for(j=2*s;j<=m;j*=2) {
if(j<m&&H.Heap[j]<H.Heap[j+1]) ++j;
if(c>=H.Heap[j]) break;
H.Heap[s]=H.Heap[j];
s=j;
}
H.Heap[s]=c;
}
PrintSqList(struct Sqlist H)
{
int i;
for(i=1;i<N;i++)
printf("%d ",H.Heap[i]);
printf("%d\n",H.Heap[N]);
}
main()
{
struct Sqlist H;
InitSqList(H);
HeapSort(H);
PrintSqList(H);
}