社区讨论

求助

P1104生日参与者 6已保存回复 10

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
9 条
当前快照
1 份
快照标识符
@mk168vpo
此快照首次捕获于
2026/01/05 21:03
上个月
此快照最后确认于
2026/01/09 13:30
上个月
查看原帖
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;
}

回复

10 条回复,欢迎继续交流。

正在加载回复...