社区讨论
求猪 闭关
P1104生日参与者 10已保存回复 16
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 16 条
- 当前快照
- 1 份
- 快照标识符
- @mk15q9t4
- 此快照首次捕获于
- 2026/01/05 20:49 上个月
- 此快照最后确认于
- 2026/01/09 13:15 上个月
CPP
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
struct B {
string name;
int ye;
int mon;
int d;
};
bool compare(const B& a, const B& b) {
if (a.ye != b.ye) return a.ye > b.ye;
if (a.mon != b.mon) return a.mon > b.mon;
return a.d > b.d;
}
int main() {
int n;
cin >> n;
vector<B> bi(n);
for (int i = 0; i < n; ++i) {
cin >> bi[i].name >> bi[i].ye >> bi[i].mon >> bi[i].d;
}
sort(bi.begin(), bi.end(), compare);
for (const auto& b : bi) {
cout << b.name << endl;
}
return 0;
}
回复
共 16 条回复,欢迎继续交流。
正在加载回复...