Algorithm/PS
[BOJ/백준] 26546 - Reverse [python]
chanwoong1
2023. 3. 6. 00:18
728x90
26546번: Reverse
The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will be one line with a string and two integers i and j, separated by spaces. The first int, i, is the start index of the substring to be taken
www.acmicpc.net
문제 풀이
문자열 중, 입력값으로 주어진 i와 j사이의 인덱스는 출력하지 않는 문제이다. 따라서, 문자열 인덱스 0부터 i까지, j부터 문자열의 끝까지 출력할 수 있도록 코드를 작성했다.
정답 코드
for _ in range(int(input())) :
s, i, j = input().split()
for x in range(int(i)) :
print(s[x], end = "")
for x in range(int(j), len(s)) :
print(s[x], end = "")
print()
728x90