Problem
"*"의 높이와 너비를 1이라고 했을 때, "*"을 이용해 직각 이등변 삼각형을 그리려고합니다. 정수 n 이 주어지면 높이와 너비가 n 인 직각 이등변 삼각형을 출력하도록 코드를 작성해보세요.
Solution
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let input = [];
rl.on('line', function (line) {
input = line.split(' ');
}).on('close', function () {
for(let i = 1; i <= Number(input[0]); i++){
console.log("*".repeat(i));
}
});
"*".repeat(i) : "*"를 i만큼 반복
'프로그래머스 (JS) > Lv. 0' 카테고리의 다른 글
[Programmers] 120862번 - 최댓값 만들기(2) (0) | 2023.03.02 |
---|---|
[Programmers] 120845번 - 주사위 개수 (0) | 2023.03.02 |
[Programmers] 120905번 - n의 배수 고르기 (0) | 2023.03.02 |
[Programmers] 120850번 - 문자열 정렬하기(1) (0) | 2023.03.02 |
[Programmers] 120892번 - 암호 해독 (0) | 2023.03.02 |