#include <vector>
#include <deque>
#include <algorithm>
#include <iostream>
#include <string>
#include <list>
using namespace std;
class person {
public:
person(string name, int age,int height) {
this->name = name;
this->age = age;
this->height = height;
}
string name;
int age;
int height;
};
bool compare(person& p1, person& p2) {
if (p1.age == p2.age) {
return p1.height > p2.height ;
}
return p1.age < p2.age;
}
void test() {
list<person>l;
person p1("a", 35, 175);
person p2("b", 45, 180);
person p3("c", 40, 170);
person p4("d", 25, 190);
person p5("e", 35, 160);
person p6("f", 35, 200);
l.push_back(p1);
l.push_back(p2);
l.push_back(p3);
l.push_back(p4);
c++自定义排序
最新推荐文章于 2024-07-09 22:37:42 发布