백준 주소: https://www.acmicpc.net/problem/23738
23738번: Ресторан
최대 $100$글자의 단어가 주어진다. 모든 글자는 영어 대문자 A, B, E, K, M, H, O, P, C, T, Y, X 중 하나로 이루어져 있다. 입력이 러시아어 대문자로 주어지지 않음에 주의하자.
www.acmicpc.net
아이디어: 러시아러를 해당하는 알파벳으로 바꿔준 후에 소문자로 바꿔주었다.
#include <iostream>
#include <string>
using namespace std;
int main() {
string word;
cin >> word;
string result = "";
for (char c : word) {
if (c == 'B') result += "v";
else if (c == 'E') result += "ye";
else if (c == 'H') result += "n";
else if (c == 'P') result += "r";
else if (c == 'C') result += "s";
else if (c == 'Y') result += "u";
else if (c == 'X') result += "h";
else result += c;
}
for (int i = 0; i < result.size(); i++) {
if ('A' <= result[i] && result[i] <= 'Z') {
result[i] += 32;
}
}
cout << result << endl;
return 0;
}
'공부 > 알고리즘, 백준' 카테고리의 다른 글
백준 유튜브 보고 공부한거 (0) | 2023.08.07 |
---|---|
c++ 에서 return 0 을 안하면 (0) | 2023.07.25 |
알고리즘 tip - for문에서의 <,> (0) | 2023.07.03 |
백준 2711번 C++ (2) | 2023.07.02 |
백준 28295번 C++ (1) | 2023.07.02 |