C语言编程 填空题

发布网友 发布时间:2022-04-24 04:44

我来回答

1个回答

热心网友 时间:2023-10-29 08:25

void HeapCreat(SqList *s, int i, int length){
int j=2*i+1;
int temp;
while(j < length){
if(j+1<length && s->a[j]<s->a[j+1]){
j++;
}
if(s->a[i] < s->a[j]){
temp=s->a[i];
s->a[i]=s->a[j];
s->a[j]=temp;
i=j ;
j=2*i+1;
}
else{
return;
}
}
}
void HeapSort(SqList *s){
int i,temp;
for(i=s->length/2-1;i>=0;i--){
HeapCreat(s,i,len-1);
}
for(i=s->length-1;i>0;i--){
temp=s->a[i];
s->a[i]=s->a[0];
s->a[0]=temp;
HeapCreat(s,0,i-1);
}
}

热心网友 时间:2023-10-29 08:25

void HeapCreat(SqList *s, int i, int length){
int j=2*i+1;
int temp;
while(j < length){
if(j+1<length && s->a[j]<s->a[j+1]){
j++;
}
if(s->a[i] < s->a[j]){
temp=s->a[i];
s->a[i]=s->a[j];
s->a[j]=temp;
i=j ;
j=2*i+1;
}
else{
return;
}
}
}
void HeapSort(SqList *s){
int i,temp;
for(i=s->length/2-1;i>=0;i--){
HeapCreat(s,i,len-1);
}
for(i=s->length-1;i>0;i--){
temp=s->a[i];
s->a[i]=s->a[0];
s->a[0]=temp;
HeapCreat(s,0,i-1);
}
}

热心网友 时间:2023-10-29 08:25

void HeapCreat(SqList *s, int i, int length){
int j=2*i+1;
int temp;
while(j < length){
if(j+1<length && s->a[j]<s->a[j+1]){
j++;
}
if(s->a[i] < s->a[j]){
temp=s->a[i];
s->a[i]=s->a[j];
s->a[j]=temp;
i=j ;
j=2*i+1;
}
else{
return;
}
}
}
void HeapSort(SqList *s){
int i,temp;
for(i=s->length/2-1;i>=0;i--){
HeapCreat(s,i,len-1);
}
for(i=s->length-1;i>0;i--){
temp=s->a[i];
s->a[i]=s->a[0];
s->a[0]=temp;
HeapCreat(s,0,i-1);
}
}

热心网友 时间:2023-10-29 08:25

void HeapCreat(SqList *s, int i, int length){
int j=2*i+1;
int temp;
while(j < length){
if(j+1<length && s->a[j]<s->a[j+1]){
j++;
}
if(s->a[i] < s->a[j]){
temp=s->a[i];
s->a[i]=s->a[j];
s->a[j]=temp;
i=j ;
j=2*i+1;
}
else{
return;
}
}
}
void HeapSort(SqList *s){
int i,temp;
for(i=s->length/2-1;i>=0;i--){
HeapCreat(s,i,len-1);
}
for(i=s->length-1;i>0;i--){
temp=s->a[i];
s->a[i]=s->a[0];
s->a[0]=temp;
HeapCreat(s,0,i-1);
}
}

热心网友 时间:2023-10-29 08:25

void HeapCreat(SqList *s, int i, int length){
int j=2*i+1;
int temp;
while(j < length){
if(j+1<length && s->a[j]<s->a[j+1]){
j++;
}
if(s->a[i] < s->a[j]){
temp=s->a[i];
s->a[i]=s->a[j];
s->a[j]=temp;
i=j ;
j=2*i+1;
}
else{
return;
}
}
}
void HeapSort(SqList *s){
int i,temp;
for(i=s->length/2-1;i>=0;i--){
HeapCreat(s,i,len-1);
}
for(i=s->length-1;i>0;i--){
temp=s->a[i];
s->a[i]=s->a[0];
s->a[0]=temp;
HeapCreat(s,0,i-1);
}
}

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com