Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8-YIM2UL2ET #27

Merged
merged 6 commits into from
Mar 10, 2024
Merged

8-YIM2UL2ET #27

merged 6 commits into from
Mar 10, 2024

Conversation

YIM2UL2ET
Copy link
Collaborator

@YIM2UL2ET YIM2UL2ET commented Mar 4, 2024

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ

BOJ 10994 - ๋ณ„ ์ฐ๊ธฐ 19

โœ”๏ธ ์†Œ์š”๋œ ์‹œ๊ฐ„

์•ฝ 90m

โœจ ์ˆ˜๋„ ์ฝ”๋“œ

1. ๋ฌธ์ œ ์„ค๋ช…

n์„ ์ž…๋ ฅ ๋ฐ›๊ณ , ๊ทœ์น™์— ๋”ฐ๋ผ ๋ณ„์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.

2. ๋ฌธ์ œ ๋ถ„์„ ๋ฐ ํ’€์ด ๋ฐฉ์‹

๋ณ„์ฐ๊ธฐ ๋ฌธ์ œ ํ’€ ๋•Œ๋งˆ๋‹ค ๋Š๋ผ๋Š”๊ฑด๋ฐ ๊ทœ์น™ ์ฐพ๊ธฐ๋Š” ํž˜๋“ ๋ฐ, ๋‹ต์ด ์˜ˆ์ƒ ์™ธ๋กœ ์‰ฌ์šด ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค..
๋งˆ์Œ ๊ฐ™์•„์„œ๋Š” ์ œ๊ฐ€ ์ ‘๊ทผํ–ˆ์—ˆ๋˜ ๋ฐฉ์‹ ์ „๋ถ€ ์ ๊ณ  ์‹ถ์ง€๋งŒ.. ๊ทธ๋Ÿฌ๋ฉด ํ•œ ์„ธ์›”์ด ๊ฑธ๋ฆด ๊ฒƒ ๊ฐ™๊ธฐ์—
์ •๋‹ต์ด์—ˆ๋˜ ์ ‘๊ทผ ๋ฐฉ๋ฒ•๊ณผ ํ’€์ด ๋ฐฉ์‹๋งŒ ์˜ฌ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.

1. ์ถœ๋ ฅ ๋ชจ์–‘ ๋ถ„์„

์šฐ์„  ๋ณ„๋“ค์ด ์ถœ๋ ฅ๋˜๋Š” ํฌ๊ธฐ๋ฅผ ํ•œ๋ฒˆ ๋ด…์‹œ๋‹ค. n์ด 5์ผ ๋•Œ๋ฅผ ํ•œ๋ฒˆ ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
// ์‚ฌ์ง„

์•ˆ์ชฝ ์‚ฌ๊ฐํ˜•์˜ ์‚ฌ์ด์ฆˆ๋„ ๊ฐ๊ฐ n์ด 1~4์ผ ๋•Œ์˜ ์‚ฌ์ด์ฆˆ์™€ ๊ฐ™๊ธฐ ๋•Œ๋ฌธ์— ํ‘œ๋กœ ๋‚˜ํƒ€๋‚ด๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

n ํ…Œ๋‘๋ฆฌ ํฌ๊ธฐ
1 1
2 5
3 9
4 13
n 4n-3

ํ…Œ๋‘๋ฆฌ์˜ ํฌ๊ธฐ๋Š” 4n-3 ์—์„œ ์•ˆ์ชฝ์œผ๋กœ ๊ฐˆ์ˆ˜๋ก 4์”ฉ ์ค„์–ด๋“ ๋‹ค๋Š” ๊ทœ์น™์„ ํ™•์ธ ํ–ˆ์Šต๋‹ˆ๋‹ค.
์˜ˆ์™ธ์ ์œผ๋กœ 1์ผ ๋•Œ๋Š” ๋ณ„์ด ํ•˜๋‚˜๋ฐ–์— ๋˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์ผ๋‹จ์€ 1์„ ์˜ˆ์™ธ ์ผ€์ด์Šค๋กœ ์ƒ๊ฐํ•ด๋ด…์‹œ๋‹ค.

2. ์ถœ๋ ฅ ๋ฐฉ์‹ ๊ฒฐ์ •

(์ €๋Š” ์ด ๋ถ€๋ถ„์ด ์ •๋ง ์–ด๋ ค์› ์Šต๋‹ˆ๋‹ค..)
์ด ๋ถ€๋ถ„์€ ๊ฐœ์ธ์ ์œผ๋กœ๋Š” ์ฐฝ์˜์„ฑ์ด ์žˆ์–ด์•ผ ํ’€ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์šฐ์„  ์ฒซ ๋‘ ์ค„๊ณผ, ๋งˆ์ง€๋ง‰ ๋‘ ์ค„์„ ๋ฎ๊ฐœ๋ผ๊ณ  ์ƒ๊ฐํ•ด๋ด…์‹œ๋‹ค.
์ด๋Š” ์ตœ์ดˆ n์„ ์ด์šฉํ•˜์—ฌ ๋งจ ์œ—์ค„๊ณผ ๋งจ ์•„๋ž˜์ค„์„ *์„ 4n-3๋ฒˆ ์ถœ๋ ฅํ•˜๋Š” ํ˜•์‹์œผ๋กœ,
๋งจ ์œ„์—์„œ ๋‘๋ฒˆ์งธ์ค„๊ณผ ๋งจ ์•„๋ž˜์—์„œ ๋‘๋ฒˆ์งธ์ค„์€ *์„ ์–‘ ๋์— ์ถœ๋ ฅ ํ›„ ์„ 4n-5๋ฒˆ ์ถœ๋ ฅํ•˜๋Š” ํ˜•์‹์œผ๋กœ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ทธ ๋‹ค์Œ ์ค„์„ ์ƒ๊ฐํ•ด๋ด…์‹œ๋‹ค.
n์„ ์ƒ๊ฐํ•˜๋ฉด ๋„๋ฌด์ง€ ๊ทœ์น™์„ ์ฐพ์„ ์ˆ˜ ์—†๊ฒ ์ง€๋งŒ, ์šฐ๋ฆฌ๋Š” ์•ˆ์ชฝ์œผ๋กœ ๊ฐˆ ์ˆ˜๋ก ํ…Œ๋‘๋ฆฌ๊ฐ€ 4์”ฉ ์ค„์–ด๋“ญ๋‹ˆ๋‹ค.
์ด๋•Œ ํ…Œ๋‘๋ฆฌ์˜ ํฌ๊ธฐ๋Š” 4n-3์—์„œ 4(n-1)-3์ด ๋˜๋ฏ€๋กœ n์ด 1๋งŒํผ ์ค„์–ด๋“ ๋‹ค ์ƒ๊ฐํ•˜๋ฉด ๋˜๊ฒ ์ง€์š”.

//์‚ฌ์ง„

๊ทธ๋ ‡๋‹ค๋ฉด n-1๋กœ ์ƒ๊ฐ์„ ํ•ด์„œ ์„ธ๋ฒˆ์งธ์™€ ๋„ค๋ฒˆ์งธ์ค„, n-2๋ฒˆ์งธ์™€ n-3๋ฒˆ์งธ ์ค„์„ ๋ด…์‹œ๋‹ค.
n์œผ๋กœ ์ƒ๊ฐํ–ˆ๋‹ค๋ฉด ๋‹ฌ๋ž๊ฒ ์ง€๋งŒ n-1๋กœ ์ƒ๊ฐํ–ˆ์œผ๋ฏ€๋กœ ์‚ฌ์ง„์— ๋‚˜์™€์žˆ๋Š” ๋ถ€๋ถ„์„ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋ฎ๊ฐœ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ์‹œ๋‹ค.

๋ฎ๊ฐœ๋Š” ์œ„์˜ ๋ฐฉ์‹๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ์ถœ๋ ฅํ•˜๋ฉด ๋˜๊ฒ ์ง€์š”.
์ด๋ ‡๊ฒŒ ๋œ๋‹ค๋ฉด ์–‘ ๋์— ์žˆ๋Š” ๋ณ„๋„ ์‰ฝ๊ฒŒ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
n์ด ์ค„์–ด๋“  ๋งŒํผ ์–‘ ๋์— * ์™€ *์„ ์ถœ๋ ฅํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ์—†์–ด์ง‘๋‹ˆ๋‹ค.

๊ทธ ๋‹ค์Œ ์ค„์„ ๋ณด์•„๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ž…๋‹ˆ๋‹ค. n-2๋งŒํผ ์–‘ ๋ ๋ณ„์„ ์ถœ๋ ฅ ํ•˜๋ฉด์„œ 4(n-2)-3ํฌ๊ธฐ์˜ ๋ฎ๊ฐœ๋ฅผ ์ถœ๋ ฅํ•˜๊ณ ,
n-3์˜ ๋ฎ๊ฐœ๋ฅผ ์ถœ๋ ฅํ•ด๋‚˜๊ฐ€๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๋งŒ์•ฝ์— n์ด 1์ด ๋œ๋‹ค๋ฉด ๊ทธ๋•Œ๋Š” n-1๋ฒˆ์˜ ์–‘ ๋ ๋ณ„์„ ์ถœ๋ ฅํ•˜๊ณ , ๋ณ„ ํ•˜๋‚˜๋ฅผ ์ถœ๋ ฅํ•˜๋ฉด ๋์ด ๋‚˜๊ฒ ์ง€์š”?
์ด๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ณ ์ณ์„œ

์ด๋ฅผ ๊ฐ„๋‹จํžˆ ํ‘œํ˜„ํ•ด๋ด…์‹œ๋‹ค.

  1. n์ด ์ค„์–ด๋“  ๋งŒํผ ์–‘ ๋์— ๊ฐ๊ฐ * ์™€ *์„ ์ถœ๋ ฅํ•˜๊ณ , ๊ทธ ์‚ฌ์ด์— 4n-3์˜ ํฌ๊ธฐ๋กœ ์œ„์˜ ๋ฎ๊ฐœ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
  2. n = 1์ด ์•„๋‹ˆ๋ผ๋ฉด n์„ -1 ์ค„์—ฌ์ฃผ๊ณ  1๋ฒˆ์œผ๋กœ ๋Œ์•„๊ฐ„๋‹ค.
  3. n = 1์ด๋ฉด n-1๋ฒˆ ์–‘ ๋์— ๊ฐ๊ฐ * ์™€ *์„ ์ถœ๋ ฅํ•˜๊ณ , ๊ทธ ์‚ฌ์ด์— *์„ ์ถœ๋ ฅํ•œ ํ›„ ์ข…๋ฃŒํ•œ๋‹ค.

3. ํ•จ์ˆ˜ ๊ตฌํ˜„

๊ฐ™์€ ๋ฐฉ์‹์˜ ์ฝ”๋“œ๊ฐ€ ๋ฐ˜๋ณต์ ์œผ๋กœ ์‹คํ–‰์ด ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์žฌ๊ท€ํ•จ์ˆ˜๋กœ ๊ตฌํ˜„์ด ๊ฐ€๋Šฅํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
์œ„์™€ ๊ฐ™์€ ๊ทœ์น™์œผ๋กœ ๋ณ„์„ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ star ํ•จ์ˆ˜๋กœ ๊ตฌํ˜„ํ•ด ๋ณด๊ธฐ ์ „์—
star ํ•จ์ˆ˜์— ๋“ค์–ด๊ฐ€๊ฒŒ ๋˜๋Š” ๋ฎ๊ฐœ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜์ธ cover1 ๊ณผ cover2 ๋ผ๋Š” ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

level์€ n์ด ์ค„์–ด๋“  ํฌ๊ธฐ์ž…๋‹ˆ๋‹ค.

void cover1(int n, int level)
{
    for (int i = 0; i < level; i++) std::cout << "* ";
    for (int i = 0; i < 4*(n-level)-3; i++) std::cout << "*";
    for (int i = 0; i < level; i++) std::cout << " *";
    std::cout << "\n";
}

void cover2(int n, int level)
{
    for (int i = 0; i < level; i++) std::cout << "* ";
    std::cout << "*";
    for (int i = 0; i < 4*(n-level)-5; i++) std::cout << " ";
    std::cout << "*";
    for (int i = 0; i < level; i++) std::cout << " *";
    std::cout << "\n";
}

cover1 ํ•จ์ˆ˜๋Š” *********, ***** ๋“ฑ์„ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜์ด๊ณ ,
cover2 ํ•จ์ˆ˜๋Š” * *, * * ๋“ฑ์„ ์ถœ๋ ฅํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

์ด๋ฅผ ์ด์šฉํ•˜์—ฌ ์žฌ๊ท€ํ•จ์ˆ˜์ธ star ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•ด๋ด…์‹œ๋‹ค.

void star(int n, int level)
{
    if (n == level+1) {    // ์ค„์–ด๋“  n์ด 1์ด ๋˜๋ฉด ๊ฐ€์šด๋ฐ์ค„ ์ถœ๋ ฅ
        for (int i = 0; i < n*2-2; i++) std::cout << "* ";
        std::cout << "*\n";
    }
    else {
        cover1(n, level);
        cover2(n, level);
        star(n, level+1);
        cover2(n, level);
        cover1(n, level);
    }
}

4. ์ตœ์ข… ์ฝ”๋“œ

#include <iostream>

void cover1(int n, int level)
{
    for (int i = 0; i < level; i++) std::cout << "* ";
    for (int i = 0; i < 4*(n-level)-3; i++) std::cout << "*";
    for (int i = 0; i < level; i++) std::cout << " *";
    std::cout << "\n";
}

void cover2(int n, int level)
{
    for (int i = 0; i < level; i++) std::cout << "* ";
    std::cout << "*";
    for (int i = 0; i < 4*(n-level)-5; i++) std::cout << " ";
    std::cout << "*";
    for (int i = 0; i < level; i++) std::cout << " *";
    std::cout << "\n";
}

void star(int n, int level)
{
    if (n == level+1) {
        for (int i = 0; i < n*2-2; i++) std::cout << "* ";
        std::cout << "*\n";
    }
    else {
        cover1(n, level);
        cover2(n, level);
        star(n, level+1);
        cover2(n, level);
        cover1(n, level);
    }
}

int main(void)
{
    int n;
    std::cin >> n;
    star(n, 0);
    return 0;
}

๐Ÿ“š ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ

๊ทธ๋ž˜ํ”„๋ฅผ ๊ณต๋ถ€ํ•˜๊ธฐ ์ „์— ์žฌ๊ท€๋ฅผ ์ง‘์ค‘์ ์œผ๋กœ ์—ฐ์Šตํ•˜๊ณ  ์‹ถ์–ด์„œ ์ด๋ฒˆ์ฃผ๋Š” ์•„๋งˆ ์žฌ๊ท€๋ฅผ ์ง‘์ค‘์ ์œผ๋กœ ์—ฐ์Šตํ•˜์ง€ ์•Š์„๊นŒ ์‹ถ์Šต๋‹ˆ๋‹ค.
๊ฐœ์ธ์ ์œผ๋กœ ์žฌ๊ท€ ๋„ˆ๋ฌด ํž˜๋“œ๋„ค์š”..

Copy link
Collaborator

@rivkms rivkms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

โœ”๏ธ ๊ฐœ์ธ์ ์œผ๋กœ ์ œ๊ฐ€ ํ’€๊ธฐ๋„ ์–ด๋ ค์› ๊ณ , PR์˜ ์•„์ด๋””์–ด๋„ ์–ด๋ ต๊ฒŒ ๋”ฐ๋ผ๊ฐ”๋˜, ๋‚œํ•ดํ•œ ๋ฌธ์ œ์˜€๋˜ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ฌผ๋ก  PR์€ ๋ฉ‹์ง€๊ฒŒ ์ž˜ ์จ์ฃผ์…จ์ง€๋งŒ, ์•„์ด๋””์–ด๊ฐ€ ๋…์ฐฝ์ ์ด์…”์„œ ๋”ฐ๋ผ๊ฐ€๊ธฐ๊ฐ€ ์–ด๋ ค์› ๋˜ ๋ถ€๋ถ„์ด ์žˆ๊ธฐ๋„ ํ–ˆ๋„ค์š”

โœ”๏ธ ๋•๋ถ„์— ์ด๋Ÿฐ ๋ฌธ์ œ์— ๋Œ€ํ•œ ํ’€์ด๋ฅผ ํ•˜๋‚˜ ์•Œ์•„๊ฐ„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

โœ”๏ธ ์ด๊ฒŒ ๊ฐ€๋Šฅํ• ์ง€๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ, ํ˜น์‹œ Queue๊ฐ™์€ ๊ฒƒ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ’€ ์ˆ˜๋„ ์žˆ์ง€ ์•Š์„๊นŒ๋„ ์ƒ๊ฐํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๊ฐ€์šด๋ฐ๋ถ€ํ„ฐ ์ฑ„์›Œ๋‚˜๊ฐ€๋ฉฐ ํ•ด๋‹น queue ์•ž๊ณผ ๋’ค์— ๋‹ค๋ฅธ ๋‚ด์šฉ์„ ์ฑ„์›Œ๋„ฃ๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•  ์ˆ˜๋Š” ์—†์„์ง€๋„ ๊ณ ๋ฏผํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

โœ”๏ธ ๊ทผ๋ฐ ๋” ์ƒ๊ฐ์„ ํ•ด๋ณด๋ฉด, ์ง์ ‘ ์ฝ”๋“œ๋กœ ์งœ๋ณด์ง€๋Š” ๋ชปํ•˜์˜€์ง€๋งŒ, ์ด๋Ÿฌํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ํ•˜๋ฉด ๊ตฌํ˜„ํ•˜๋Š”๋ฐ ์žˆ์–ด ๋” ์–ด๋ ค์šธ ๊ฒƒ ๊ฐ™๊ธฐ๋„ ํ•ด์„œ... ์‚ฌ์‹ค ์ด ์•„์ด๋””์–ด๋Š” ์ €๋„ ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ•ด์•ผํ• ์ง€ ๋ชฐ๋ผ์„œ...๊ณ ๋ฏผ์ด๋„ค์š”

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค ๐Ÿ˜

@YIM2UL2ET
Copy link
Collaborator Author

โœ”๏ธ ์ด๊ฒŒ ๊ฐ€๋Šฅํ• ์ง€๋Š” ๋ชจ๋ฅด๊ฒ ์ง€๋งŒ, ํ˜น์‹œ Queue๊ฐ™์€ ๊ฒƒ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ฌธ์ œ๋ฅผ ํ’€ ์ˆ˜๋„ ์žˆ์ง€ ์•Š์„๊นŒ๋„ ์ƒ๊ฐํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๊ฐ€์šด๋ฐ๋ถ€ํ„ฐ ์ฑ„์›Œ๋‚˜๊ฐ€๋ฉฐ ํ•ด๋‹น queue ์•ž๊ณผ ๋’ค์— ๋‹ค๋ฅธ ๋‚ด์šฉ์„ ์ฑ„์›Œ๋„ฃ๋Š” ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•  ์ˆ˜๋Š” ์—†์„์ง€๋„ ๊ณ ๋ฏผํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

์ €๋„ ์ž๋ฃŒํ˜• ๋‹ค์–‘ํ•˜๊ฒŒ ์ƒ๊ฐํ•˜๋ฉด์„œ ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ• ๊นŒ ์ƒ๊ฐํ•ด ๋ณด์•˜๋‹ค๊ฐ€ ๋‚˜์˜จ ํ’€์ด๊ฐ€ ์ €๊ฒ๋‹ˆ๋‹ค. ์ฐพ์•„๋ณด์ง„ ์•Š์•˜์ง€๋งŒ ์ œ๊ฐ€ ์ƒ๊ฐํ•œ ํ’€์ด ์ด์™ธ์—๋„ ์ด๋Ÿฐ ๋ณ„์ฐ๊ธฐ ๋ฌธ์ œ๋Š” ๋ฏผ์„ฑ๋‹˜์ฒ˜๋Ÿผ ํ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ’€์ด ๋“ฑ, ๋‹ค์–‘ํ•œ ํ’€์ด๋ฒ•์ด ๋งŽ์„ ๊ฒƒ ๊ฐ™๋„ค์š”. ํ•œ๋ฒˆ ์ฐพ์•„๋ด์•ผ๊ฒ ์Šต๋‹ˆ๋‹ค.

Copy link
Member

@kjs254 kjs254 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฌธ์ œ๋ฅผ ๋ณด์•˜์„ ๋• ๊ฐ„๋‹จํ•ด ๋ณด์ด์ง€๋งŒ ๋ง‰์ƒ ์ ‘๊ทผํ•˜๋ ค๋‹ˆ ์‰ฝ์ง€ ์•Š๋„ค์š”. ์•„๋งˆ ํ’€์ด ๋ฐฉ๋ฒ•์ด ๋‹ค์–‘ํ•ด์„œ ๊ทธ๋Ÿฐ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์ง์ ‘ ๊ทธ๋ฆผ์„ ๊ทธ๋ ค๋ณด๋‹ˆ ์ •์‚ฌ๊ฐํ˜• ๋ฌด๋Šฌ๊ฐ€ ์—ฐ์†์ ์œผ๋กœ ์ปค์ง€๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๊ณ  ๋ฐ˜๋ณต์ ์ธ ํŒจํ„ด์ด ๋ณด์ด๋ฏ€๋กœ ์žฌ๊ท€์ ์œผ๋กœ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ์ด ๋‹น์—ฐํ•ด ๋ณด์ž…๋‹ˆ๋‹ค.

star(int n, int level) ํ•จ์ˆ˜์—์„œ level ์ด๋ผ๋Š” ๋ณ€์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ์žฌ๊ท€์ ์œผ๋กœ ์ ‘๊ทผํ•˜๋Š” ๊ฒƒ๋„ ์ข‹์•˜์ง€๋งŒ ์žฌ๊ท€๋ฅผ ์ด์šฉํ•˜์ง€ ์•Š๊ณ  ์ •์‚ฌ๊ฐํ˜• 2์ฐจ์› ๋ฐฐ์—ด์„ ์‹œ๊ณ„ ๋ฐฉํ–ฅ์œผ๋กœ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์–ด๋–จ์ง€ ๊ถ๊ธˆํ•˜๋„ค์š”.

Copy link
Collaborator

@mong3125 mong3125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ํ’€๊ณ  ํ’€์ด๋ฐฉ๋ฒ•์„ ๋ณด๋Š”๋ฐ ์ œ ๋ฐฉ๋ฒ•์ด๋ž‘ ์™„์ „ ๋˜‘๊ฐ™๋„ค์š”. ๊ทผ๋ฐ ์ฝ”๋“œ๊ฐ€ ํ›จ์”ฌ ๊ฐ„๋‹จํ•˜๊ณ  ์ง๊ด€์ ์ด๋ผ ์ž˜ ๋ฐฐ์šฐ๊ณ  ๊ฐ‘๋‹ˆ๋‹ค. ์ž˜ ๋ดค์Šต๋‹ˆ๋‹ค!!

์ถœ๋ ฅํ•˜์‹ค๋•Œ ๋ฒ„ํผ๋ฅผ ์ด์šฉํ•˜์‹œ๋Š”๊ฒƒ๋„ ์ถ”์ฒœ๋“œ๋ ค์š”!
stdio ๊ธฐ๋ณธ ์ถœ๋ ฅ ํ•จ์ˆ˜ ์†๋„ ๋น„๊ต

๊ฒ€์ƒ‰์„ ํ•ด๋ณด๋‹ˆ c++์˜ string์€ java์™€ ๋‹ค๋ฅด๊ฒŒ ๊ฐ€๋ณ€์ ์ด๋ผ๊ณ  ํ•˜๋Š”๋ฐ ๋งž๋‹ค๋ฉด string์„ ๋งŒ๋“ค์–ด์„œ ์ฝ”๋“œ๋ฅผ ๋Œ๋ฉด์„œ ์ถ”๊ฐ€ํ•œ ๋’ค์— ์ตœ์ข…์ ์œผ๋กœ ๊ฒฐ๊ณผ(string)๋ฅผ ์ถœ๋ ฅํ•˜๋Š”๊ฒƒ๋„ ์ข‹์€ ๋ฐฉ๋ฒ•์ผ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

@YIM2UL2ET
Copy link
Collaborator Author

ํ’€๊ณ  ํ’€์ด๋ฐฉ๋ฒ•์„ ๋ณด๋Š”๋ฐ ์ œ ๋ฐฉ๋ฒ•์ด๋ž‘ ์™„์ „ ๋˜‘๊ฐ™๋„ค์š”. ๊ทผ๋ฐ ์ฝ”๋“œ๊ฐ€ ํ›จ์”ฌ ๊ฐ„๋‹จํ•˜๊ณ  ์ง๊ด€์ ์ด๋ผ ์ž˜ ๋ฐฐ์šฐ๊ณ  ๊ฐ‘๋‹ˆ๋‹ค. ์ž˜ ๋ดค์Šต๋‹ˆ๋‹ค!!

์ถœ๋ ฅํ•˜์‹ค๋•Œ ๋ฒ„ํผ๋ฅผ ์ด์šฉํ•˜์‹œ๋Š”๊ฒƒ๋„ ์ถ”์ฒœ๋“œ๋ ค์š”! stdio ๊ธฐ๋ณธ ์ถœ๋ ฅ ํ•จ์ˆ˜ ์†๋„ ๋น„๊ต

๊ฒ€์ƒ‰์„ ํ•ด๋ณด๋‹ˆ c++์˜ string์€ java์™€ ๋‹ค๋ฅด๊ฒŒ ๊ฐ€๋ณ€์ ์ด๋ผ๊ณ  ํ•˜๋Š”๋ฐ ๋งž๋‹ค๋ฉด string์„ ๋งŒ๋“ค์–ด์„œ ์ฝ”๋“œ๋ฅผ ๋Œ๋ฉด์„œ ์ถ”๊ฐ€ํ•œ ๋’ค์— ์ตœ์ข…์ ์œผ๋กœ ๊ฒฐ๊ณผ(string)๋ฅผ ์ถœ๋ ฅํ•˜๋Š”๊ฒƒ๋„ ์ข‹์€ ๋ฐฉ๋ฒ•์ผ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

์•„์ด๋””์–ด ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ํ™•์‹คํžˆ string ๊ฐ์ฒด ๋งŒ๋“ค์–ด์„œ ํ™œ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ๋งค๋ ฅ ์žˆ์„ ๊ฒƒ ๊ฐ™๋„ค์š”!

@YIM2UL2ET YIM2UL2ET merged commit d9fc0fc into main Mar 10, 2024
@YIM2UL2ET YIM2UL2ET deleted the 8-YIM2UL2ET branch March 10, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants