프로그래머스 문제

문자열 반복해서 출력하기

nakgopsae 2024. 6. 6. 19:21

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = sc.nextInt();
        String result = "";
        for(int i = 1; i <= n ; i++){
            result += str;
        }
        System.out.println(result);
    }//for 문으로 입력받은 문자를 result에 넣기
}