#include <iostream>
using namespace std;
struct student
{
char name[20];
int score;
};
void main()
{
student s[5];
for(int i=0;i<5;i++)
{
cin>>s[i].name;
cin>>s[i].score;
}
for(int k=0;k<4;k++)
for(int t=0;t<4-k;t++)
{
student tmp;
if(s[t].score>s[t+1].score)
{
tmp=s[t];
s[t]=s[t+1];
s[t+1]=tmp;
}
}
for(int j=0;j<5;j++)
{
cout<<"姓名:"<<s[j].name<<" ";
cout<<"分数:"<<s[j].score<<" ";
cout<<endl;
}
}
温馨提示:内容为网友见解,仅供参考