T-coding
백준 17413 단어 뒤집기 2 / Python 본문
728x90
728x90
https://www.acmicpc.net/problem/17413
코드
더보기
s = input()
stack = []
tag = False
ans = ''
for i in s:
if i == '>':
tag = False
ans += i
elif i == '<':
while stack:
ans += stack.pop()
ans += i
tag = True
elif i == ' ':
while stack:
ans += stack.pop()
ans += i
elif tag:
ans += i
else:
stack.append(i)
while stack:
ans += stack.pop()
print(ans)
728x90
300x250
'Baekjoon' 카테고리의 다른 글
백준 14670 병약한 영정 / Python (0) | 2023.03.24 |
---|---|
백준 15720 카우버거 / Python (0) | 2023.03.23 |
백준 14499 주사위 굴리기 / Python (0) | 2023.03.21 |
백준 3190 뱀 / Python (0) | 2023.03.21 |
백준 14503 로봇 청소기 / Python (0) | 2023.03.21 |