|

楼主 |
发表于 2020-12-15 14:29:14
|
显示全部楼层
- #include <stdio.h>
- int main()
- {
- int N, m, i, j;
- scanf("%d", &N);
- struct stu
- {
- char name[25];
- int year;
- int month;
- int day;
- } stu[N], t;
- for (m = 0; m < N; m++)
- {
- scanf("%s", stu[m].name);
- scanf("%d %d %d", &stu[m].year, &stu[m].month, &stu[m].day);
- }
- for (i = 0; i < N; i++)
- {
- for (j = i + 1; j < N; j++)
- {
- }
- for (int i = 0; i < N; i++)
- {
- for (int j = i + 1; j < N; j++)
- {
- if (stu[i].year > stu[j].year)
- {
- t = stu[j];
- stu[j] = stu[i];
- stu[i] = t;
- }
- else if (stu[i].year == stu[j].year)
- {
- if (stu[i].month > stu[j].month)
- {
- t = stu[j];
- stu[j] = stu[i];
- stu[i] = t;
- }
- else if (stu[i].month == stu[j].month)
- {
- if (stu[i].day >= stu[j].day)
- {
- t = stu[j];
- stu[j] = stu[i];
- stu[i] = t;
- }
- }
- }
- }
- }
- for (m = 0; m < N; m++)
- printf("%s\n", stu[m].name);
- return 0;
- }
- }
复制代码 |
|