[프로그래머스] 자바 - 직사각형 별찍기
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();
}
}
}
궁금한게 원래 나와있던 코드 지우고 내맘대로 해도 되는게 맞는건가..?통과는 되는데..
'Algorithm Study > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 자바 - 핸드폰 번호 가리기 (0) | 2021.10.19 |
---|---|
[프로그래머스] 자바 - x만큼 간격이 있는 n개의 숫자 (0) | 2021.10.19 |
[프로그래머스] 자바 - 짝수와 홀수 (0) | 2021.10.18 |
[프로그래머스] 자바 - 평균구하기 (0) | 2021.10.18 |