오락기/codeWar
2675 백준 문자열반복
문방구앞오락기
2018. 5. 11. 15:45
https://www.acmicpc.net/problem/2675
S를 입력받운후에 R번 반복해 T를 출력
첫번째 줄은 줄수
첫번째 엘리먼트 첫번째껀 횟수 두번째껀 반복해야할 문자열
.input
2 3 ABC 5 /HTP
out
AAABBBCCC /////HHHHHTTTTTPPPPP
code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import java.util.*; public class Main { public static void main(String[] args) { //97~122 아스키 a-z Scanner sc = new Scanner(System.in); String count = sc.nextLine().trim(); String[] input = new String[Integer.parseInt(count)]; int copyCount = 0; String sum=""; for(int i=0; i< (Integer.parseInt(count)) ; i++) { sum=""; input[i] = sc.nextLine().trim(); copyCount = Integer.parseInt(input[i].substring(0, 1)); input[i] = input[i].substring(1, input[i].length()).trim(); for(int j=0 ; j<input[i].length() ;j++) { for(int k=0; k<copyCount ;k++) sum += input[i].charAt(j); } System.out.println(sum); } } } |