# 생각
범위가 넘어갈 때 조절을 주의해서 조건문을 구현하면 된다
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
'Algorithm > BOJ' 카테고리의 다른 글
[BOJ] 2559_수열.cpp (0) | 2022.05.29 |
---|---|
[BOJ] 9996_한국이 그리울 땐 서버에 접속하지.cpp (0) | 2022.05.29 |
[BOJ] 1159_농구 경기.cpp (0) | 2022.05.28 |
[BOJ] 10988_팰린드롬인지 확인하기.cpp (0) | 2022.05.28 |
[BOJ] 2979_트럭 주차.cpp (0) | 2022.05.28 |