๐Ÿ• Baaaaaarking/0x02๊ฐ• - ๊ธฐ์ดˆ ์ฝ”๋“œ ์ž‘์„ฑ ์š”๋ น II

[BOJ][C++] ๋ฐฑ์ค€ 2442๋ฒˆ: ๋ณ„ ์ฐ๊ธฐ -5

์„ ๋‹ฌ 2023. 5. 22. 23:04
๋ฐ˜์‘ํ˜•

https://www.acmicpc.net/problem/2442

 

2442๋ฒˆ: ๋ณ„ ์ฐ๊ธฐ - 5

์ฒซ์งธ ์ค„์—๋Š” ๋ณ„ 1๊ฐœ, ๋‘˜์งธ ์ค„์—๋Š” ๋ณ„ 3๊ฐœ, ..., N๋ฒˆ์งธ ์ค„์—๋Š” ๋ณ„ 2×N-1๊ฐœ๋ฅผ ์ฐ๋Š” ๋ฌธ์ œ ๋ณ„์€ ๊ฐ€์šด๋ฐ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋Œ€์นญ์ด์–ด์•ผ ํ•œ๋‹ค.

www.acmicpc.net

 

#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    for(int i=1; i<=n; i++) {
        for(int j=n-i; j>0; j--) cout << " ";
        for(int j=0; j<i*2 - 1; j++) cout << "*";
        cout << "\n";
    }
    return 0;
}
๋ฐ˜์‘ํ˜•