File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 26
26
#include "problems/problem_2741.h"
27
27
#include "problems/problem_2742.h"
28
28
#include "problems/problem_2908.h"
29
+ #include "problems/problem_5635.h"
29
30
#include "problems/problem_8393.h"
30
31
31
32
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ ProblemManager::ProblemManager() {
25
25
problems_[2742 ] = solve_problem_2742;
26
26
problems_[2557 ] = solve_problem_2557;
27
27
problems_[2908 ] = solve_problem_2908;
28
+ problems_[5635 ] = solve_problem_5635;
28
29
problems_[8393 ] = solve_problem_8393;
29
30
problems_[10950 ] = solve_problem_10950;
30
31
problems_[10952 ] = solve_problem_10952;
Original file line number Diff line number Diff line change
1
+ #include " problem_5635.h"
2
+ #include < iostream>
3
+ #include < vector>
4
+
5
+ void solve_problem_5635 () {
6
+ std::cout << " === 5635번 생일 문제 해결 ===" << std::endl;
7
+
8
+ int n;
9
+ std::cout << " 정수 n을 입력하세요 (예: 3) : " ;
10
+ std::cin >> n;
11
+
12
+ std::vector<Student> students (n);
13
+
14
+ for (int i = 0 ; i < n; i++) {
15
+ std::cin >> students[i].name >> students[i].day >> students[i].month >> students[i].year ;
16
+ }
17
+
18
+ Student oldest = students[0 ];
19
+ Student youngest = students[0 ];
20
+
21
+ for (int i = 1 ; i < n; i++) {
22
+ if (students[i].year < oldest.year ||
23
+ (students[i].year == oldest.year && students[i].month < oldest.month ) ||
24
+ (students[i].year == oldest.year && students[i].month == oldest.month && students[i].day < oldest.day )) {
25
+ oldest = students[i];
26
+ }
27
+
28
+ if (students[i].year > youngest.year ||
29
+ (students[i].year == youngest.year && students[i].month > youngest.month ) ||
30
+ (students[i].year == youngest.year && students[i].month == youngest.month && students[i].day > youngest.day )) {
31
+ youngest = students[i];
32
+ }
33
+ }
34
+
35
+ std::cout << " 가장 나이가 적은 사람: " << youngest.name << " \n " ;
36
+ std::cout << " 가장 나이가 많은 사람: " << oldest.name << " \n " ;
37
+
38
+ std::cout << " ================================" << std::endl;
39
+ }
Original file line number Diff line number Diff line change
1
+ #ifndef PROBLEM_5635_H
2
+ #define PROBLEM_5635_H
3
+
4
+ #include < string>
5
+
6
+ class Student {
7
+ public:
8
+ std::string name;
9
+ int day;
10
+ int month;
11
+ int year;
12
+ };
13
+
14
+ void solve_problem_5635 ();
15
+
16
+ #endif
You can’t perform that action at this time.
0 commit comments