[ Programmers ] 직사각형 별 찍기 (Java)

ma.caron_g·2021년 8월 29일
0

Lv.1 - Programmers (완성)

목록 보기
26/74
post-thumbnail

1. Problem 📃


2. Constraint 🔗



3. Solution 🔑

for문을 이용하여 문제 해결
n, m을 입력 받을 때
1. 첫번째 for문은 "행" n줄 만큼
2. 두번째 for문은 "열"로 생각하여 *을 m개 만큼 출력해주면 됩니다

4. Code 💻

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        for(int i=0; i<b; i++) {
        	for(int j=0; j<a; j++) {
        		System.out.print("*");
        	}
        	System.out.println();
        }
    }
}
profile
다른 사람이 만든 것을 소비하는 활동보다, 내가 생산적인 활동을 하는 시간이 더 많도록 생활화 하자.

0개의 댓글