이 문제에는 표준 입력으로 두 개의 정수 n과 m이 주어집니다.
별(*) 문자를 이용해 가로의 길이가 n, 세로의 길이가 m인 직사각형 형태를 출력해보세요.
입력
5 3
출력
*****
*****
*****
process.stdin.setEncoding('utf8');
process.stdin.on('data', data => {
const n = data.split(" ");
const a = Number(n[0]), b = Number(n[1]);
let rectangle = "";
for (let i = 0; i < b; i++) {
rectangle += "*".repeat(a) + "\n"; // 가로 길이만큼 별 반복 후 줄바꿈
}
console.log(rectangle)
});
process.stdin.setEncoding('utf8');
process.stdin.on('data', data => {
const n = data.split(" ");
const a = Number(n[0]), b = Number(n[1]);
console.log((('*').repeat(a)+`\n`).repeat(b))
});
오… repeat() 두 번 사용하는 방법도 있구나