※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 26502번 문제인 Decoder이다.
문제는 아래 링크를 확인하자.

https://www.acmicpc.net/problem/26502 

 

26502번: Decoder

A positive integer, n, on the first line. After the first line there will be n lines of encrypted text.

www.acmicpc.net

주어진 표와 같이 주어진 문자열의 문자들을 바꿔 문제를 해결하자.

 

소문자만이 아닌 대문자 또한 바꿔줘야 함에 유의하자.

 

아래는 제출한 소스코드이다.

#include <iostream>
#include <string>
using namespace std;

int T;
string s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> T;
	getline(cin, s);
	while (T--) {
		getline(cin, s);
		for (auto& l : s) {
			if (l == 'a') cout << 'e';
			else if (l == 'e') cout << 'i';
			else if (l == 'i') cout << 'o';
			else if (l == 'o') cout << 'u';
			else if (l == 'u') cout << 'y';
			else if (l == 'y') cout << 'a';
			else if (l == 'A') cout << 'E';
			else if (l == 'E') cout << 'I';
			else if (l == 'I') cout << 'O';
			else if (l == 'O') cout << 'U';
			else if (l == 'U') cout << 'Y';
			else if (l == 'Y') cout << 'A';
			else cout << l;
		}
		cout << '\n';
	}
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 26535 // C++] Chicken Pen  (0) 2022.12.21
[BOJ 10187 // C++] Golden  (0) 2022.12.21
[BOJ 26536 // C++] Cowspeak  (0) 2022.12.21
[BOJ 26560 // C++] Period  (0) 2022.12.21
[BOJ 26547 // C++] Square  (0) 2022.12.21

+ Recent posts