TA的每日心情 | 擦汗 前天 09:07 |
---|
签到天数: 527 天 连续签到: 4 天 [LV.9]测试副司令
|
1测试积点
- ```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");
- }
复制代码
|
|