结构体定义、结构体数组、排序

结构体定义和数组声明
1.

struct 结构体名称{
    变量类型 变量名;
};
struct 结构体名称 结构体变量名;
struct 结构体名称 结构体数组名[数组长度];

2.

typedef struct Student
{
int age;
int score;
int sno;
}Stu;
Stu stu1;
Stu stu2[30];

排序
如果对结构体排序,使用algorithm,需要对cmp函数重定义

bool cmp(Stu a,Stu b)
{
if(a.age

猜你喜欢

转载自blog.csdn.net/qq_37357873/article/details/82491782