관리 메뉴

Storage Gonie

(28) [C++] 백준 No.10991 별찍기 - 16 본문

알고리즘/백준풀이1. 입출력

(28) [C++] 백준 No.10991 별찍기 - 16

Storage Gonie 2019. 4. 21. 01:20
반응형

문제

풀이

# C++

#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);

    int N = 0;

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N-i-1; j++)
            cout << " ";

        for (int j = 0; j < 2*(i+1)-1; j++)
            if (j % 2 == 0)
                cout << "*";
            else
                cout << " ";
                
        cout << endl;
    }
}
반응형
Comments