//分数统计 要求1.输入某班学生的姓名,分数; 2.对1的分数进行排序,按分数从大到小输出
struct student
{
char name[10];
int score;
};
#define N 3
#include"stdio.h"
main()
{
struct student stu[N]={{"li",95},{"zhang",77},{"wang",81}};
struct student *stud[N]={&stu[0],&stu[1],&stu[2]},*p;
int i,j;
for(i=0;i<N-1;i++)
for(j=i+1;j<N;j++)
if(stud[i]->score>=stud[j]->score)
{
p=stud[i];
stud[i]=stud[j];
stud[j]=p;
}
printf("name
score:\n");
for(i=0;i<N;i++)
printf("%-10s%-d\n",stud[i]->name,stud[i]->score);
}