luogu P1104 生日

 1 #include <iostream>
 2 #include <algorithm>
 3 using namespace std;
 4 struct stu
 5 {
 6     string name;
 7     int y;
 8     int m;
 9     int d;
10     int id;
11     friend bool operator < (stu a,stu b)
12     {
13         if (a.y != b.y)
14         {
15             if (a.y < b.y)
16                 return false;
17             else
18                 return true;
19         }else if (a.m != b.m)
20         {
21             if (a.m < b.m)
22                 return false;
23             else
24                 return true;
25         }else if (a.d != b.d)
26         {
27             if (a.d < b.d)
28                 return false;
29             else
30                 return true;
31         }else
32         {
33             if (a.id < b.id)
34                 return true;
35             else
36                 return false;
37         }
38     }
39 };
40 stu a[110];
41 int n;
42 int main()
43 {
44     cin >> n;
45     for (int i = 1;i <= n;i++)
46     {
47         cin >> a[i].name >> a[i].y >> a[i].m >> a[i].d;
48         a[i].id = i;
49     }
50     sort(a + 1,a + n + 1);
51     for (int i = n;i >= 1;i--)
52         cout << a[i].name <<endl;
53 }

 

posted @ 2019-07-25 11:42  IAT14  阅读(188)  评论(0编辑  收藏  举报