[Java] 백준 문제 풀이 - 2675번

이진석·2022년 11월 18일
0

백준 문제 풀이!!

목록 보기
10/13
post-thumbnail

20221118

문제

첫째 줄에 테스트 케이스의 개수 T(1 ≤ T ≤ 1,000)가 주어진다. 각 테스트 케이스는 반복 횟수 R(1 ≤ R ≤ 8), 문자열 S가 공백으로 구분되어 주어진다. S의 길이는 적어도 1이며, 20글자를 넘지 않는다.


풀이

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int T = sc.nextInt(); // 테스트 케이스의 개수
        int R; // 반복횟수
        String S;

        for(int i=0;i<T;i++){
            R = sc.nextInt();
            S = sc.next();
        
            for(int x=0, cnt=S.length();x<cnt;x++){
                for(int y=0;y<R;y++){
                    System.out.print(S.charAt(x));
                }
             }
          System.out.println();
        }
    }
}
profile
혼자서 코딩 공부하는 전공생 초보 백엔드 개발자 / https://github.com/leejinseok0614

0개의 댓글

Powered by GraphCDN, the GraphQL CDN