[프로그래머스] 자바 - 직사각형 별찍기

2021. 10. 19. 15:49

import java.util.Scanner;

class Solution {
    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);
    }
}

 

<풀이>

import java.util.Scanner;

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();
        }
    }
}

 

궁금한게 원래 나와있던 코드 지우고 내맘대로 해도 되는게 맞는건가..?통과는 되는데..

BELATED ARTICLES

more