[백준2442_자바스크립트(javascript)] - 별 찍기 - 5

경이·2024년 1월 9일

𝑩𝑶𝑱 (𝒋𝒔)

목록 보기
26/325

🔴 문제

별 찍기 - 5


🟡 Sol

const fs = require('fs');
const path = process.platform === 'linux' ? '/dev/stdin' : 'Wiki\\input.txt';
const n = Number(fs.readFileSync(path).toString());

for (let i = 1; i <= n; i++) {
  console.log(' '.repeat(n - i) + '*'.repeat(i * 2 - 1));
}

🟢 풀이

기존의 별찍기에서 곱하기 2 한후 1씩 빼주면된다.

🔵 Ref

profile
록타르오가르

0개의 댓글