# 생각

범위가 넘어갈 때 조절을 주의해서 조건문을 구현하면 된다

getline으로 공백도 같이 입력받는다

 

 

# 전체 코드

#include <bits/stdc++.h>
using namespace std;

void fastIO() { ios::sync_with_stdio(false); cin.tie(nullptr); }

int main()
{
	fastIO();
	string s;
	getline(cin, s);
	int sz = s.size();
	for (int i = 0; i < sz; i++)
	{
		if (s[i] >= 'A' and s[i] <= 'Z')
		{
			if (s[i] + 13 > 'Z')
			{
				s[i] -= 13;
			}
			else
			{
				s[i] += 13;
			}
		}
		else if (s[i] >= 'a' and s[i] <= 'z')
		{
			if (s[i] + 13 > 'z')
			{
				s[i] -= 13;
			}
			else
			{
				s[i] += 13;
			}
		}
		cout << s[i];
	}
}

 


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

 

+ Recent posts