공부/프로그래머스
문자열 반복해서 출력하기
딸기버블티
2023. 7. 6. 20:57
문제 설명
문자열 str과 정수 n이 주어집니다.
str이 n번 반복된 문자열을 만들어 출력하는 코드를 작성해 보세요.
나의 풀이
1
2
3
4
5
6
7
8
9
10
11
12
|
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
int n = sc.nextInt();
for(int i=0; i<n; i++){
System.out.print(str);
}
}
}
|
cs |