C++)
#include <iostream>
#include <string>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string str;
getline(cin, str);
string ans = "";
for (auto ch : str) {
if (!isalpha(ch)) {
ans += ch;
continue;
}
if (islower(ch))
ans += (ch - 'a' + 13) % 26 + 'a';
else
ans += (ch - 'A' + 13) % 26 + 'A';
}
cout << ans;
return 0;
}
Python)
import sys
temp = sys.stdin.readline().rstrip()
ans = ''
for ch in temp:
if not ch.isalpha():
ans += ch
continue
temp = ord(ch) + 13
if ch.islower():
ans += chr((ord(ch) - ord('a') + 13) % 26 + ord('a'))
else:
ans += chr((ord(ch) - ord('A') + 13) % 26 + ord('A'))
print(ans)'백준 1 > 기초' 카테고리의 다른 글
| [백준 10824] 네 수 (C++/Python) (0) | 2020.12.05 |
|---|---|
| [백준 10808] 알파벳 개수 (C++ / Python) (0) | 2020.12.05 |
| [백준 2743] 단어 길이 재기 (C++/Python) (0) | 2020.12.05 |
| [백준 10886] 0 = not cute / 1 = cute (C++/Python) (0) | 2020.12.05 |
| [백준 10992] 별 찍기 - 17 (C++) (0) | 2020.12.05 |