设计-个英雄的结构体,包括成员姓名,年龄,性别;创建结构体数组,数组中存放5名英雄。
通过冒泡排序的算法,将数组中的英雄按照年龄进行升序排序,最终打印排序后的结果。
函数和无函数两种
#include <iostream>
using namespace std;
#include <string>//sizeof string
struct yingxiong
{
string name;
int age;
string sex;
};
//函数解决
void paixu(struct yingxiong pArry[], int len);
void dayin(struct yingxiong pArry[], int len);
int main()
{
struct yingxiong arr[5] =
{
{