C++ 语法回顾(二)——结构体构造及其排序

 结构体构造

typedef struct Student{
    string name;
    int score;
}Student;

Student stu[500];

struct Student{
    string name;
    int score;
};

Student stu[500];

结构体排序

bool cmp0(Student a, Student b){    // 降序
    return a.score > b.score;
}

bool cmp1(Student a, Student b){
    return a.score < b.score;
}

stable_sort(stu, stu+n, cmp0);

 

你可能感兴趣的:(C++,基础,c++)