//输入人名和成绩,输出人名按成绩从大到小
#include<stdio.h>
struct student
{
char name[21];
char score;
};
int main()
{
struct student a[100],t;
int i,j,n;
puts("要输入几个人");
scanf("%d",&n);
printf("请输入数据");
for(i=1;i<=n;i++)
scanf("%s%d",a[i].name,&a[i].score);
for(i=1;i<n;i++)
for(j=1;j<=n-i;j++)
{
if(a[j].score<a[j+1].score)
{
t=a[j];//a【x】代表一个整体,包含score,name
a[j]=a[j+1];
a[j+1]=t;
}
}
printf("结果是:");
for(i=1;i<=n;i++)
printf("%s %d\n",a[i].name,a[i].score);
return 0;
}