출력(Print)

백준 2443번: 별찍기 - 6

cepiloth 2018. 8. 4. 14:50
반응형

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


1. 문제


2. 알고리즘

키워드 - 출력, 구현


3. 코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>         // greater 사용 위해 필요  
#include <string>
#include <map>
#include <unordered_map>
#include <math.h>
using namespace std;
 
 
int main() {
    ios::sync_with_stdio(false); cin.tie(0);  // scanf 안쓸 경우 쓰세요. Cin 사용시
 
    int n; cin >> n;
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            cout << ' ';
        }
        for (int j = i; j < n*2-1-i; j++) {
            cout << '*';
        }
        cout << "\n";
    }
    return 0;
}
cs

반응형