#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct Student{
string name;
int score[4];
};
int cmp(Student x, Student y)
{
return x.name < y.name;
}
int main()
{
Student stu[3];
for (int i = 0; i < 3; i++)
{
cin >> stu[i].name;
for (int j = 0; j < 4; j++)
{
cin >> stu[i].score[j];
}
}
sort(stu, stu + 3, cmp);
for (int i = 0; i < 3; i++)
{
cout << stu[i].name << ":";
for (int j = 0; j < 4; j++)
{
cout << stu[i].score[j] << " ";
}
cout << endl;
}
return 0;
}
结构体数组排序简单版
最新推荐文章于 2023-01-31 22:26:58 发布