SMALL
문제)
문자열 str과 정수 n이 주어집니다.
str이 n번 번복된 문자열을 만들어 출력하는 코드를 작성해보세요.
제한사항
- 1 <= str의 길이 <= 10
- 1 <= n <= 5
입력 #1
string 5
출력 #1
stringstringstringstringstring
답
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);
}
}
}
728x90
LIST
'프로그래머스 > Java' 카테고리의 다른 글
더 크게 합치기 (0) | 2023.05.24 |
---|---|
공배수 (0) | 2023.05.24 |
문자 리스트를 문자열로 변환하기 (0) | 2023.05.24 |
댓글