프로그래머스/lv1

직사각형 별찍기

do_it0904 2022. 12. 19. 12:35
/* 직사각형 별찍기
 * 이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다.
 * 별(*) 문자를 이용해 가로의 길이가 n,
 * 세로의 길이가 m인 직사각형 형태를 출력해보세요.
 */
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.util.Scanner;
public class programmer_1_35 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
 
        System.out.println(a + b);
        for(int i = 0; i < b; i++){
            for(int k = 0; k < a; k++){
                System.out.print("*");
            }
            System.out.println("");
        }
    }
}
cs