• 数据结构 直接排序,有错误,应该怎么改,急
  • python
    1.00元

```int Partition(SeqList &L,Student a[],int low,int high)
{
a[0]=a[low];
char pivotkey=a[low].no;
while(low {
while(low=pivotkey) --high;
a[low]=a[high];
while(low<high&&a[low].no<=pivotkey) ++low;
a[high]=a[low];
}
a[low]=a[0];
return low;
}

void QSort(SeqList &L,Student a[],int low,int high)
{
if(low<high){
int pivotloc=Partition(L,a,low,high);
QSort(L,a,low,pivotloc-1);
QSort(L,a,pivotloc+1,high);
}
}
void QuickSort(SeqList &L)
{

Student a[MAXSIZE];//排序专用临时数组
   for(int i=1;i<=L.last;i++)
       a[i]=L.elem[i];
    QSort(L,a,1,L.last);
    for(i=1;i<L.last;i++)
{
   printf("学号:%s 姓名:%s 成绩:%d\n\n",L.elem[i].no,L.elem[i].name,L.elem[i].price);
}
printf("\n");

}


  • vicky    2020-06-18 10:04:20
  • 阅读 782    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信