※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 26546번 문제인 Reverse이다.
문제는 아래 링크를 확인하자.

https://www.acmicpc.net/problem/26546 

 

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가 주어질 때, 출력해야하는 문자열은 처음서부터 i 이전까지와 j부터 끝까지의 두 문자열로 구분할 수 있다.

 

각 문자열을 출력해 문제를 해결하자.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;

int T;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> T;
	while (T--) {
		string s; int L, R; cin >> s >> L >> R;
		int slen = s.length();
		for (int i = 0; i < L; i++) cout << s[i];
		for (int i = R; i < slen; i++) cout << s[i];
		cout << '\n';
	}
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 26495 // C++] Big Number  (0) 2022.12.19
[BOJ 26545 // C++] Mathematics  (0) 2022.12.19
[BOJ 6887 // C++] Squares  (0) 2022.12.19
[BOJ 26592 // C++] Triangle Height  (0) 2022.12.19
[BOJ 1809 // GolfScript] Moo  (0) 2022.12.19

+ Recent posts