언젠가는 펼쳐 볼 아카이브
[BOJ] 2444번 - 별찍기 - 7 본문
사용언어: javascript - node.js
#제출코드
const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
const input = fs.readFileSync(filePath).toString().trim();
solution(+input);
function solution(input) {
// 정방향
for (let i = 0; i < input - 1; i++) {
let star = '*'.repeat(2 * i + 1);
let space = ' '.repeat(input - i);
console.log(space + star);
}
//역방향
for (let i = input - 1; i >= 0; i--) {
let star = '*'.repeat(2 * i + 1);
let space = ' '.repeat(input - i);
console.log(space + star);
}
}
'IT > Baekjoon Oline Judge' 카테고리의 다른 글
[BOJ] 2941번 - 크로아티아 알파벳 (0) | 2023.08.22 |
---|---|
[BOJ] 1157번 - 단어 공부 (0) | 2023.08.22 |
[BOJ] 10988번 - 팰린드롬인지 확인하기 (0) | 2023.08.22 |
[BOJ] 3003번 - 킹, 퀸, 룩, 비숍, 나이트, 폰 (0) | 2023.08.18 |
[BOJ] 25083번 - 새싹 (0) | 2023.08.18 |