https://www.acmicpc.net/problem/6321
6321번: IBM 빼기 1
첫째 줄에 컴퓨터의 개수 n이 주어진다. 다음 줄부터 n개의 줄에는 컴퓨터의 이름이 주어진다. 컴퓨터의 이름은 최대 50글자이며, 알파벳 대문자로만 이루어져 있다.
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
def sol(s):
ans = ''
for i in s:
if (ord(i) + 1) <= 90:
ans += chr(ord(i) + 1)
else:
ans += chr(ord(i) + 1 - 26)
return ans
n=int(input())
for i in range(n):
print("String #%d"%(i+1))
s=input()
print(sol(s))
if i!= n-1:
print()
|
cs |
이 문제는 입력받은 문자열을 알파벳 오른쪽으로 하나씩 쉬프팅 하는 문제죠
Z 다음 문자가 A라는것(Line 6-7), 그리고 출력형태(Line 15-16) 고려하시면 됩니다
In this problem, Input is String, it is just shifting alphabet to the right
Specially you consider Z next A(Line 6-7) , and Output Format(Line 15-16)
반응형
'python-algorithm' 카테고리의 다른 글
백준 25377 빵 (0) | 2022.10.08 |
---|---|
백준 25628 햄버거 만들기 (0) | 2022.10.07 |
백준 11557 Yangjojang of The Year (0) | 2022.10.05 |
백준 25642 젓가락 게임 (0) | 2022.10.05 |
백준 2605 줄 세우기 (0) | 2022.10.04 |
댓글