백준 문제/구현

[백준] 2443번 별 찍기 - 6

dubu0721 2025. 1. 4. 19:47

문제: 2443번: 별 찍기 - 6

basic-algo-lecture/workbook/0x02.md at master · encrypted-def/basic-algo-lecture

 

basic-algo-lecture/workbook/0x02.md at master · encrypted-def/basic-algo-lecture

바킹독의 실전 알고리즘 강의 자료. Contribute to encrypted-def/basic-algo-lecture development by creating an account on GitHub.

github.com

 

#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip> // setprecision을 사용하기 위한 헤더
#include <climits>

using namespace std;

int main() {
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++)
            cout << " ";

        for (int j = 0; j < (n * 2) - 1 - (i * 2); j++) {
            cout << "*";
        }

        cout << "\n";
    }


    return 0;
}

 

음. 처음에 푼 코드가 틀려서 보니까 별 뒤에는 공백을 출력하면 안 되는 것이었다..

 

출력 드래그 해서 보니까 별로 끝나더라.. ㅎㅎ;

 

 

 

참고자료:

[바킹독의 실전 알고리즘] 0x02강 - 기초 코드 작성 요령 II - YouTube