‡ CODING TEST STUDY ‡/º 백준
[백준 | Java Bronze III] (#11721) 열 개씩 끊어 출력하기
Trudy | 송연
2024. 6. 22. 16:53
문제
11721번: 열 개씩 끊어 출력하기 (acmicpc.net)
문자열 연산 - Substring 함수
문자열.substring(시작 인덱스, 마지막 인덱스 + 1);
//시작 인덱스 ~ 끝까지
문자열.substring(시작 인덱스);
최종 코드
package week8.baek;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class B11721 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();
for (int i = 0; i < input.length(); i+=10) {
if(i+10 < input.length()) System.out.println(input.substring(i, i + 10));
else System.out.println(input.substring(i));
}
}
}