#include <iostream>
#include <string>
using namespace std;
struct Hero
{
string name;
int age;
string sex;
};
void sortage (struct Hero h[])
{
Hero l;
for(int i=0;i<4;i++)
{
if(h[i].age>=h[i+1].age)
{
l=h[i+1];
h[i+1]=h[i];
h[i]=l;
}
}
}
void printAll (struct Hero h[])
{
for(int i=0;i<5;i++)
{
cout<<"姓名 "<<h[i].name;
cout<<"年龄 "<<h[i].age;
cout<<"性别 "<<h[i].sex<<endl;
}
}
int main() {
struct Hero h[5]=
{
{"刘备",23,"男"},
{"关羽",22,"男"},
{"张飞",20,"男"},
{"赵云",21,"男"},
{"貂蝉",18,"女"},
}
sortage(h);
printAll(h);
return 0;
}