Skip to content

Commit 71c02e0

Browse files
committed
feat: 5635번 문제 해결
1 parent cddfb85 commit 71c02e0

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

src/problem_includes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "problems/problem_2741.h"
2727
#include "problems/problem_2742.h"
2828
#include "problems/problem_2908.h"
29+
#include "problems/problem_5635.h"
2930
#include "problems/problem_8393.h"
3031

3132

src/problem_manager.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ProblemManager::ProblemManager() {
2525
problems_[2742] = solve_problem_2742;
2626
problems_[2557] = solve_problem_2557;
2727
problems_[2908] = solve_problem_2908;
28+
problems_[5635] = solve_problem_5635;
2829
problems_[8393] = solve_problem_8393;
2930
problems_[10950] = solve_problem_10950;
3031
problems_[10952] = solve_problem_10952;

src/problems/problem_5635.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
}

src/problems/problem_5635.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

0 commit comments

Comments
 (0)