반응형
주어진 글자를 10글자씩 나눠 출력하는 문제
|
문제 |
알파벳 소문자와 대문자로만 이루어진 길이가 N인 단어가 주어진다.
한 줄에 10글자씩 끊어서 출력하는 프로그램을 작성하시오.
|
소스 |
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); String input = sc.nextLine(); int last = input.length()/10; for(int i=0; i<=last; i++) { if (i == last) { System.out.println(input.substring(i*10, input.length())); } else { System.out.println(input.substring(i*10, i*10+10)); } } } }
|
출처 |
반응형
'알고리즘 > JAVA' 카테고리의 다른 글
| [JAVA] 백준 알고리즘 9498 : 시험 성적 (0) | 2018.07.30 |
|---|---|
| [JAVA] 백준 알고리즘 15552 : 빠른 A+B (0) | 2018.07.30 |
| [JAVA] 백준 알고리즘 11720 : 숫자의 합 (0) | 2018.07.30 |
| [JAVA] 백준 알고리즘 8393 : 합 (0) | 2018.07.30 |
| [JAVA] 백준 알고리즘 2441 : 별찍기 - 4 (0) | 2018.07.30 |