๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์•Œ๊ณ ๋ฆฌ์ฆ˜

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค1๋‹จ๊ณ„ : ์ง์‚ฌ๊ฐํ˜• ๋ณ„์ฐ๊ธฐ

by _ํ† ๋งคํ†  2022. 11. 28.
728x90

๐Ÿ–ฑ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 1๋‹จ๊ณ„ : ์ง์‚ฌ๊ฐํ˜• ๋ณ„์ฐ๊ธฐ ๐Ÿ–ฑ


๐Ÿ“– ๋ฌธ์ œ ์„ค๋ช… ๐Ÿ“–

์ด ๋ฌธ์ œ์—๋Š” ํ‘œ์ค€ ์ž…๋ ฅ์œผ๋กœ ๋‘ ๊ฐœ์˜ ์ •์ˆ˜ n๊ณผ m์ด ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. ๋ณ„(*) ๋ฌธ์ž๋ฅผ ์ด์šฉํ•ด ๊ฐ€๋กœ์˜ ๊ธธ์ด๊ฐ€ n, ์„ธ๋กœ์˜ ๊ธธ์ด๊ฐ€ m์ธ ์ง์‚ฌ๊ฐํ˜• ํ˜•ํƒœ๋ฅผ ์ถœ๋ ฅํ•ด๋ณด์„ธ์š”.

๐Ÿงธ ์ œํ•œ ์‚ฌํ•ญ ๐Ÿงธ

n๊ณผ m์€ ๊ฐ๊ฐ 1000 ์ดํ•˜์ธ ์ž์—ฐ์ˆ˜์ž…๋‹ˆ๋‹ค.

process.stdin.setEncoding('utf8');
    process.stdin.on('data', data => {
        const n = data.split(" ");
        const a = Number(n[0]), b = Number(n[1]);
        const star = "*".repeat(a)
        for(let i = 0; i < b; i++){
            console.log(star)
        }
});
// arr1 == [[1,2],[2,3]] arr2 == [[3,4],[5,6]]์ผ ๋•Œ [[4,6],[7,9]]๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
// arr1 == [[1],[2]] arr2 == [[3],[4]]์ผ ๋•Œ [[4],[6]]๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿงธ ๋ฌธ์ œ ํ’€์ด ๐Ÿงธ

1. data๋ฅผ ํ•จ์ˆ˜๋กœ ๋ฐ›์•„์˜จ ํ›„ split()๋กœ ๋‚˜๋ˆ„์–ด์ค๋‹ˆ๋‹ค.
2. ๋ฌธ์ž์—ด data๋ฅผ ์ˆซ์ž๋กœ ๋ณ€ํ™˜ํ•ด์ค๋‹ˆ๋‹ค.
3. repeat๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด "*"๋ฌธ์ž์—ด์„ ๋ฐ˜๋ณตํ•˜์—ฌ ๋ถ™์—ฌ์ค๋‹ˆ๋‹ค.


๐Ÿงธ ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ํ’€์ด ๐Ÿงธ

process.stdin.setEncoding('utf8');
    process.stdin.on('data', data => {
        const n = data.split(" ");
        const a = Number(n[0]), b = Number(n[1]);
        const star = `${'*'.repeat(a)}\n`;
    
        console.log(star.repeat(b));
});

๋น„์Šทํ•˜์ง€๋งŒ ์กฐ๊ธˆ์”ฉ ๋‹ค๋ฅด๋„ค์š”!

728x90

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css