From 1c29093123684dd11c91d954311500be6810eec4 Mon Sep 17 00:00:00 2001 From: sh0723 Date: Fri, 22 May 2026 16:55:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?1213=20:=20=ED=8C=B0=EB=A6=B0=EB=8D=94?= =?UTF-8?q?=EB=A1=AC=20=EB=A7=8C=EB=93=A4=EA=B8=B0=20v1=20solve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week1/BOJ1213/BOJ1213_V1.cpp | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/week1/BOJ1213/BOJ1213_V1.cpp diff --git a/src/week1/BOJ1213/BOJ1213_V1.cpp b/src/week1/BOJ1213/BOJ1213_V1.cpp new file mode 100644 index 0000000..a3a264f --- /dev/null +++ b/src/week1/BOJ1213/BOJ1213_V1.cpp @@ -0,0 +1,99 @@ +#include +using namespace std; + +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); + int cnt[26] = {0}; + string input; + int alphabet_count = 0; + int check_odd_or_even = 0; + int odd_num = -1; + cin >> input; + +// 1. 입력값에 들어있는 알파벳이 몇종류? + 2. 알파벳의 각종류가 몇개씩 갖고있음? + for (int i=0; i 홀수인것 제외하고 나머지를 순서대로 개수/2 해서 result string에 더하고 하나는 reverse 시킨후 홀수인 스트링 중간에 더해서 만듬 + string result_front = "" , result_middle = "", result_back = ""; + if (alphabet_count == 2 && odd_num != -1) { + for (int i=0; i<26; i++) { + if (cnt[i] != 0) { + for (int j=0; j<(cnt[i]/2); j++) { + result_front += (char)('A' + i); + result_back += (char)('A' + i); + } + } + + } + result_middle += (char)('A'+ odd_num); + result_front += result_middle; + reverse(result_back.begin(), result_back.end()); + result_front += result_back; + + cout << result_front << "\n"; + return 0; + } + + if (check_odd_or_even == 1) { + for (int i=0; i<26; i++) { + if (i == odd_num) { + result_middle += (char)('A' + odd_num); + continue; + } + if (cnt[i] != 0) { + for (int j=0; j<(cnt[i]/2); j++) { + result_front += (char)('A' + i); + result_back += (char)('A' + i); + } + } + } + } else { + for (int i=0; i<26; i++) { + if (cnt[i] != 0) { + for (int j=0; j<(cnt[i]/2); j++) { + result_front += (char)('A' + i); + result_back += (char)('A' + i); + } + } + } + } + + result_front += result_middle; + reverse(result_back.begin(), result_back.end()); + result_front += result_back; + + cout << result_front << "\n"; + +} \ No newline at end of file From 2297abe58147fae332305cdb47cf788db0329cab Mon Sep 17 00:00:00 2001 From: sh0723 Date: Fri, 22 May 2026 17:20:02 +0900 Subject: [PATCH 2/2] =?UTF-8?q?1213=20:=20=ED=8C=B0=EB=A6=B0=EB=93=9C?= =?UTF-8?q?=EB=A1=AC=20=EB=A7=8C=EB=93=A4=EA=B8=B0=20sovle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/week1/BOJ1213/BOJ1213_V1.cpp | 103 +++++++------------------------ 1 file changed, 21 insertions(+), 82 deletions(-) diff --git a/src/week1/BOJ1213/BOJ1213_V1.cpp b/src/week1/BOJ1213/BOJ1213_V1.cpp index a3a264f..94f8d2c 100644 --- a/src/week1/BOJ1213/BOJ1213_V1.cpp +++ b/src/week1/BOJ1213/BOJ1213_V1.cpp @@ -1,99 +1,38 @@ #include using namespace std; - +int cnt[26]; +string input; +int odd_num = -1; +int odd_count; int main() { - ios::sync_with_stdio(false); - cin.tie(NULL); - int cnt[26] = {0}; - string input; - int alphabet_count = 0; - int check_odd_or_even = 0; - int odd_num = -1; + cin >> input; -// 1. 입력값에 들어있는 알파벳이 몇종류? + 2. 알파벳의 각종류가 몇개씩 갖고있음? for (int i=0; i 홀수인것 제외하고 나머지를 순서대로 개수/2 해서 result string에 더하고 하나는 reverse 시킨후 홀수인 스트링 중간에 더해서 만듬 - string result_front = "" , result_middle = "", result_back = ""; - if (alphabet_count == 2 && odd_num != -1) { - for (int i=0; i<26; i++) { - if (cnt[i] != 0) { - for (int j=0; j<(cnt[i]/2); j++) { - result_front += (char)('A' + i); - result_back += (char)('A' + i); - } - } - - } - result_middle += (char)('A'+ odd_num); - result_front += result_middle; - reverse(result_back.begin(), result_back.end()); - result_front += result_back; - - cout << result_front << "\n"; - return 0; + string result = ""; + if (odd_count > 1) { + cout << "I'm Sorry Hansoo"; + } else if (odd_count == 1) { + result += (char)(odd_num + 'A'); } - if (check_odd_or_even == 1) { - for (int i=0; i<26; i++) { - if (i == odd_num) { - result_middle += (char)('A' + odd_num); - continue; - } - if (cnt[i] != 0) { - for (int j=0; j<(cnt[i]/2); j++) { - result_front += (char)('A' + i); - result_back += (char)('A' + i); - } - } - } - } else { - for (int i=0; i<26; i++) { - if (cnt[i] != 0) { - for (int j=0; j<(cnt[i]/2); j++) { - result_front += (char)('A' + i); - result_back += (char)('A' + i); - } - } + for (int i=25; i>=0; i--) { + for (int j=0; j<(cnt[i]/2); j++) { + result = result + (char)(i+'A'); + result = (char)(i+'A') + result; } } - result_front += result_middle; - reverse(result_back.begin(), result_back.end()); - result_front += result_back; - - cout << result_front << "\n"; - + cout << result << "\n"; + return 0; } \ No newline at end of file