문제
https://programmers.co.kr/learn/courses/30/lessons/12969?language=java
코딩테스트 연습 - 직사각형 별찍기
이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다. 별(*) 문자를 이용해 가로의 길이가 n, 세로의 길이가 m인 직사각형 형태를 출력해보세요. 제한 조건 n과 m은 각각 1000 이하인 자연수
programmers.co.kr
코드
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();
}
}
}
- Integer.parseInt() 함수 사용
'프로그래머스 > LEVEL 1' 카테고리의 다른 글
[프로그래머스/LEVEL1] 없는 숫자 더하기 (0) | 2022.01.14 |
---|---|
[프로그래머스/LEVEL1] 두 정수 사이의 합 (0) | 2022.01.14 |
[프로그래머스/LEVEL1] 가운데 글자 가져오기 (0) | 2022.01.14 |
[프로그래머스/LEVEL1] 문자열을 정수로 바꾸기 (0) | 2022.01.14 |
[프로그래머스/LEVEL1] 짝수와 홀수 (0) | 2022.01.14 |