-
11655) ROT13 c++백준코딩일기 2020. 11. 24. 11:46
문제 ) www.acmicpc.net/problem/11655
풀이 )
예제를 잘 보면,
Baekjoon Online Judge -> Onrxwbba Bayvar Whqtr // B + 13 = O
One is 1 -> Bar vf 1 // O -13 = B
이 패턴을 이용해서 문제를 풀었다.
코드 )
#include <iostream> using namespace std; string input; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); getline(cin, input); for(int i=0; i<input.length(); i++) { if( 'A' <= input[i] && input[i] <= 'M') input[i] += 13; else if( 'N' <= input[i] && input[i] <= 'Z') input[i] -= 13; else if('a' <= input[i] && input[i] <='m') input[i] +=13; else if('n' <= input[i] && input[i] <='z') input[i] -=13; } cout << input <<"\n"; }
'백준코딩일기' 카테고리의 다른 글
11656) 접미사 배열 c++ (0) 2020.12.01 10824) 네 수 c++ (0) 2020.12.01 2743) 단어 길이 재기 c++ (0) 2020.11.24 10820) 문자열 분석 c++ (0) 2020.11.24 10809) 알파벳 찾기 c++ (0) 2020.11.23