Run ID:34196

提交时间:2022-08-02 10:26:08

#include <iostream> #include <algorithm> #include <string> using namespace std; struct Friend { string name, shengri, dianhua; }p[15]; bool cmp(Friend a, Friend b) { if (a.shengri != b.shengri) return a.shengri < b.shengri; if (a.name != b.name) return a.name < b.name; return a.dianhua < b.dianhua; } int main() { int n; cin >> n; for (int i = 1; i <= n; i ++) { cin >> p[i].name >> p[i].shengri >> p[i].dianhua; } sort(p + 1, p + 1 + n, cmp); for (int i = 1; i <= n; i ++) { cout << p[i].name << " " << p[i].shengri << " " << p[i].dianhua << endl; } return 0; }