• [백준_2675] 문자열 반복

    2021. 1. 2.

    by. KimBangg

    [1] 문제

    [2] CODE

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.util.StringTokenizer;
    
    public class Main {
        public static void main(String[] args) throws Exception {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            int n = Integer.parseInt(br.readLine());
    
            for(int i = 0; i < n; i++) {
                String[] str = br.readLine().split(" ");	// 공백 분리
                int repeat = Integer.parseInt(str[0]);	// String -> int
                String S = str[1];
                for (int j = 0; j < S.length(); j++) { // 문자의 글자 별로 루프를 돌림.
                    for (int k = 0; k < repeat; k++)  { // 글자를 repeat의 수만큼 반복 출력
                        System.out.print(S.charAt(j));
                    }
                }
                System.out.println();
            }
        }
    
    
    }

    댓글