whatisthis?

๋ฐฑ์ค€ 2439 javascript (node.js) ํ’€์ด ๋ณธ๋ฌธ

ALGORITHM/BOJ (Node.js)

๋ฐฑ์ค€ 2439 javascript (node.js) ํ’€์ด

thisisyjin 2021. 12. 12. 00:07

for๋ฌธ - (10)

 

 


 

๐Ÿ’ก๋ฌธ์ œ

์ฒซ์งธ ์ค„์—๋Š” ๋ณ„ 1๊ฐœ, ๋‘˜์งธ ์ค„์—๋Š” ๋ณ„ 2๊ฐœ, N๋ฒˆ์งธ ์ค„์—๋Š” ๋ณ„ N๊ฐœ๋ฅผ ์ฐ๋Š” ๋ฌธ์ œ

ํ•˜์ง€๋งŒ, ์˜ค๋ฅธ์ชฝ์„ ๊ธฐ์ค€์œผ๋กœ ์ •๋ ฌํ•œ ๋ณ„(์˜ˆ์ œ ์ฐธ๊ณ )์„ ์ถœ๋ ฅํ•˜์‹œ์˜ค.

๐Ÿ“์ž…๋ ฅ

์ฒซ์งธ ์ค„์— N(1 ≤ N ≤ 100)์ด ์ฃผ์–ด์ง„๋‹ค.

๐Ÿ“ˆ์ถœ๋ ฅ

์ฒซ์งธ ์ค„๋ถ€ํ„ฐ N๋ฒˆ์งธ ์ค„๊นŒ์ง€ ์ฐจ๋ก€๋Œ€๋กœ ๋ณ„์„ ์ถœ๋ ฅํ•œ๋‹ค.

์˜ˆ์ œ ์ž…๋ ฅ

5

์˜ˆ์ œ ์ถœ๋ ฅ

    *
   **
  ***
 ****
*****

 


< ์ฝ”๋“œ >

 

let input = Number(require('fs').readFileSync('/dev/stdin'));
let ans ='';

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