#include<bits/stdc++.h>
using namespace std;
struct hero{
string name;
int age;
string sex;
};
//冒泡排序
void bubbleSort(hero arr[] , int len)
{
for (int i = 0; i < len - 1; i++)
{
for (int j = 0; j < len - 1 - i; j++)
{
if (arr[j].age > arr[j + 1].age)
{
hero temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
int main()
{
//创建一个英雄数组
hero h[5];
int len=sizeof(h)/sizeof(h[0]) ;
for(int i=0;i<len;i++){
cin>>h[i].name>>h[i].age>>h[i].sex;
}
for (int i = 0; i < len; i++)
{
cout << "姓名: " << h[i].name << " 性别: " << h[i].sex << " 年龄: " << h[i].age << endl;
}
bubbleSort(h, len); //排序
for (int i = 0; i < len; i++)
{
cout << "姓名: " << h[i].name << " 性别: " << h[i].sex << " 年龄: " << h[i].age << endl;
}
return 0;
}