// // 444_Who is Older?.cpp // ZjgsOj // // Created by aran on 2022/3/11. // #include <iostream> using namespace::std; struct people{ int year,month,day; string name; }; int cmp(people a,people b){ if (a.year != b.year) return a.year < b.year; else if(a.month != b.month) return a.month < b.month; else return a.day < b.day; } int main() { int T; cin >> T; for (int i = 0; i < T; i++) { people p[2]; p[0].name = "javaman"; p[1].name = "cpcs"; cin >> p[0].year >> p[0].month >> p[0].day; cin >> p[1].year >> p[1].month >> p[1].day; if (p[0].year == p[1].year && p[0].month == p[1].month && p[0].day == p[1].day) cout << "same" << endl; else{ sort(p, p+2, cmp); cout << p[0].name << endl; } } return 0; } /* Main.cc: In function 'int main()': Main.cc:38:13: error: 'sort' was not declared in this scope sort(p, p+2, cmp); ^~~~ Main.cc:38:13: note: suggested alternative: 'qsort' sort(p, p+2, cmp); ^~~~ qsort */ |
Double click to view unformatted code.