※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 21955번 문제인 Split이다.
문제는 아래 링크를 확인하자.
https://www.acmicpc.net/problem/21955
21955번: Split
In order to teach Mihai to write figures neatly, his teacher gave him for homework to write several numbers. Because he was rushing to finish his homework as quick as possible so that he can play on the computer, he wrote the numbers so close that some of
www.acmicpc.net
주어지는 짝수길이의, 각 자릿수가 0이 아닌 정수를 같은 길이로 앞뒤로 쪼개는 문제이다.
글쓴이는 주어지는 수를 정수로 입력받은 후 substr을 이용하여 문제를 해결하였다.
아래는 제출한 소스코드이다.
#include <iostream>
#include <string>
using namespace std;
int main() {
string s; cin >> s;
int slen = s.length() / 2;
cout << s.substr(0, slen) << ' ' << s.substr(slen, slen);
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 13976 // C++] 타일 채우기 2 (0) | 2021.07.02 |
---|---|
[BOJ 5032 // C++] 탄산 음료 (0) | 2021.07.01 |
[BOJ 3745 // C++] 오름세 (0) | 2021.07.01 |
[BOJ 1568 // C++] 새 (0) | 2021.07.01 |
[BOJ 3066 // C++] 브리징 시그널 (0) | 2021.07.01 |