#include
#include
#include
#define MAXSIZE 100
typedef struct Student{
char no[20];// 学号
char name[20];// 姓名
int price;// 成绩
}Student;
int sum=0;
typedef struct{
Student elem[MAXSIZE];//线性表占用的数组空间
int last;//最后一个元素的下标
}SeqList;
//快速排序(学号)
int Partition(SeqList &L,Student a[],int low,int high)
{
a[0]=a[low];
int 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(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)
{
if(L.last<1)
{
printf("空表!");
}
Student a[MAXSIZE];//排序专用临时数组
for(int i=1;i<=L.last;i++)
a[i]=L.elem[i];
QSort(L.elem,1,L.last);
for(i=0;i<L.last;i++)
{
printf("学号:%s 姓名:%s 成绩:%d\n\n",L.elem[i].no,L.elem[i].name,L.elem[i].price);
}
printf("\n");
}