-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1028.c
More file actions
39 lines (37 loc) · 1.24 KB
/
1028.c
File metadata and controls
39 lines (37 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<stdio.h>
#include<string.h>
typedef struct people
{
char name[10];
int year;
int month;
int day;
}people;
int main()
{
int n;
scanf("%d", &n);
getchar();
struct people people[n];
int count = 0;
struct people max = {"", 1814, 9, 5};
struct people min = {"", 2014, 9, 7};
for(int i = 0; i < n; i++)
{
scanf("%s %d/%d/%d", people[i].name, &people[i].year, &people[i].month, &people[i].day);
count++;
if(people[i].year < 1814 || (people[i].year == 1814 && people[i].month < 9) || ( people[i].year == 1814 && people[i].month == 9 && people[i].day < 6)|| people[i].year > 2014 || (people[i].year == 2014 && people[i].month > 9) || (people[i].year == 2014 && people[i].month == 9 && people[i].day > 6))
{
count--;
continue;
}
if((people[i].year > max.year) || (people[i].year == max.year && people[i].month > max.month) || (people[i].year == max.year && people[i].month == max.month && people[i].day > max.day))
max = people[i];
if((people[i].year < min.year) || (people[i].year == min.year && people[i].month < min.month) || (people[i].year == min.year && people[i].month == min.month && people[i].day < min.day))
min = people[i];
}
if(count == 0)
printf("0");
else
printf("%d %s %s", count, min.name, max.name);
}