-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBirthdays108.cpp
More file actions
42 lines (41 loc) · 868 Bytes
/
Birthdays108.cpp
File metadata and controls
42 lines (41 loc) · 868 Bytes
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
40
41
42
#include <iostream>
using namespace std;
int main() {
int n = 0;
char name[100][16];
int day[100];
int month[100];
int year[100];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> name[i] >> day[i] >> month[i] >> year[i];
}
int largest = 0;
int smallest = 0;
for (int i = 1; i<n; i++) {
if (year[i] <= year[smallest]) {
if (year[i]<year[smallest])
smallest = i;
else if (month[i] <= month[smallest]) {
if (month[i]<month[smallest]) {
smallest = i;
}
else if (day[i] <= day[smallest])
smallest = i;
}
}
if (year[i] >= year[largest]) {
if (year[i]>year[largest])
largest = i;
else if (month[i] >= month[largest]) {
if (month[i]>month[largest]) {
largest = i;
}
else if (day[i] >= day[largest])
largest = i;
}
}
}
cout << name[largest]<<endl << name[smallest]<<endl;
return 0;
}