当前位置:网站首页>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;
}
}
如有错误,多多指教
边栏推荐
- LeetCode二叉树系列——144.二叉树的最小深度
- Six-faced ant financial clothing, resisting the bombardment of the interviewer, came to interview for review
- 无代码开发平台应用可见权限设置入门教程
- Application of time series database in the field of ship risk management
- 查阅所连接过的WiFi所有信息(含密码)(访问历史所有WiFi连接)
- Interface automation framework, lm-easytest beta version released, use it quickly~
- ESP32 反复重启问题 Arduino屏蔽断电探测器
- Conversion between pytorch and keras (the code takes LeNet-5 as an example)
- 简单理解精确率(Precision),召回率(Recall),准确率(Accuracy),TP,TN,FP,FN
- 00后测试员摸爬滚打近一年,为是否要转行或去学软件测试的学弟们总结出了以下走心建议
猜你喜欢
容器排序案例
桌面软件开发框架大赏
The way of programmers' cultivation: do one's own responsibilities, be clear in reality - lead to the highest realm of pragmatism
3年软件测试经验面试要求月薪22K,明显感觉他背了很多面试题...
Six-faced ant financial clothing, resisting the bombardment of the interviewer, came to interview for review
(HR Interview) Most Common Interview Questions and Skilled Answers
八年测试经验,为何惨遭领导痛批:你写的测试文档还不如刚来的应届生
跳槽前,把自己弄成卷王
Jenkins自动化部署项目
如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南
随机推荐
LeetCode二叉树系列——144.二叉树的最小深度
Flask框架——Flask-Mail邮件
Application of time series database in the field of ship risk management
[论文翻译] Unpaired Image-To-Image Translation Using Cycle-Consistent Adversarial Networks
无代码开发平台应用可见权限设置入门教程
华为7年经验的软件测试总监,给所有想转行学软件测试的朋友几点建议
#第九章 子查询课后习题
5. DOM
代码杂谈:从一道面试题看学会Rust的难度
LoRaWAN网关源码分析(V1.0.2)
NFTScan 与 PANews 联合发布多链 NFT 数据分析报告
(HR Interview) Most Common Interview Questions and Skilled Answers
A new generation of open source free terminal tools, so cool
43.【list的简单属性】
00后测试员摸爬滚打近一年,为是否要转行或去学软件测试的学弟们总结出了以下走心建议
无代码开发平台全部应用设置入门教程
2022年,目前大环境下还适合转行软件测试吗?
Web消息推送之SSE
自动化测试之数据驱动DDT详细篇
The website adds a live 2d kanban girl that can dress up and interact