当前位置:网站首页>Container sorting case
Container sorting case
2022-07-30 14:30:00 【old fish 37】

#include<iostream>
using namespace std;
#include<list>
#include<string>
//创建模板
class Person
{
public:
Person(string name, int age, int high)
{
m_name = name;
m_age = age;
m_high = high;
}
public:
string m_name;
int m_age;
int m_high;
};
bool Compare(Person& p1, Person& p2)
{
if (p1.m_age == p2.m_age)
{
return p1.m_high>p2.m_high;
}
else
{
return p1.m_age > p2.m_age;
}
}
int main()
{
Person p1("刘备", 20, 150);
Person p2("关羽", 20, 170);
Person p3("张飞", 20, 190);
//创建容器 save class
list<Person>v;
v.push_back(p1);
v.push_back(p2);
v.push_back(p3);
//比较函数 重新构造
v.sort(Compare);
for (list<Person>::iterator it = v.begin(); it != v.end(); it++)
{
cout << "名字:" << it->m_name << " " << "年龄:" << it->m_age << " "
<< "身高为:" << it->m_high << endl;
}
}

如有错误,多多指教
边栏推荐
- CF338E Optimize!
- AT4108 [ARC094D] Normalization
- Huawei's 7-year-experienced software testing director, gives some advice to all friends who want to change careers to learn software testing
- 使用bat脚本以json格式导出mongo数据库中指定表数据
- 关于华为应用市场审核App无法启动的问题
- 数据中台建设(五):打破企业数据孤岛和提取数据价值
- CF338E Optimize!
- 开始学习C语言了
- Flask框架——Sijax
- pytorch学习记录(六):循环神经网络 RNN & LSTM
猜你喜欢

LeetCode二叉树系列——107.二叉树的层序遍历II

3年软件测试经验面试要求月薪22K,明显感觉他背了很多面试题...

LeetCode二叉树系列——144.二叉树的最小深度

(HR Interview) Most Common Interview Questions and Skilled Answers

ECCV 2022 | 通往数据高效的Transformer目标检测器

mongodb打破原则引入SQL,它到底想要干啥?

我为何从开发人员转做测试,3年软件测试工程师,带你聊聊这其中的秘辛

Eight years of testing experience, why was the leader criticized: the test documents you wrote are not as good as those of fresh graduates

网络安全——lcx的使用

无代码开发平台全部应用设置入门教程
随机推荐
Androd 跳转到google应用市场
【VMware虚拟机安装mysql5.7教程】
Teach you how to write an eye-catching software testing resume, if you don't receive an interview invitation, I will lose
Why do software testing have to learn automation?Talk about the value of automated testing in my eyes
网络安全——lcx的使用
[ARC092B] Two Sequences
cookie模拟登录「建议收藏」
(一)Multisim安装与入门
开始学习C语言了
权威推荐!腾讯安全DDoS边缘安全产品获国际研究机构Omdia认可
LeetCode二叉树系列——199二叉树的右视图
Flask框架——Flask-SQLite数据库
CF338E Optimize!
Still saying software testing doesn't have a midlife crisis?9 years of test engineers were eliminated
Eight years of testing experience, why was the leader criticized: the test documents you wrote are not as good as those of fresh graduates
LeetCode二叉树系列——515.最每个树行中找最大值
使用bat脚本以json格式导出mongo数据库中指定表数据
为什么做软件测试一定要学自动化?谈谈我眼中自动化测试的价值
sql中ddl和dml(sql与access的区别)
CF1320E Treeland and Viruses