#include<stdio.h>
#include"string.h"
struct student
{
int num;
char name[20];
float score;
};
void main()
{
struct student stu[50]={{1,"yangye",89},{2,"wanglin",91},{3,"shunzi"},{4,"zhangpeng",80},{5,"liuhu",99}}; /*这里为了省力,仅列举了5个名额*/
struct student *p,*q;
void change(struct student *, struct student *);
for(p=stu;p<stu+49;p++)
for(q=p+1;q<stu+50;q++)
if(p->score<q->score)
change(p,q);
printf("%s\n%s\n%s\n%s\n%s\n",stu[0].name,stu[1].name,stu[2].name,stu[3].name,stu[4].name);
}
void change(struct student *p, struct student *q)
{
int a;
char b[20];
float c;
a=p->num;
strcpy(b,p->name);
c=p->score;
p->num=q->num;
strcpy(p->name,q->name);
p->score=q->score;
q->num=a;
strcpy(q->name,b);
q->score=c;
}