ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 백준 2448번 C++ 풀이
    백준 2018. 8. 29. 00:40
    #include <iostream>
    #include <cstring>
    #include <algorithm>

    #include <cmath>

    using namespace std;
    bool buffer[3100][6144];
    void func(int x, int y, int length){
    if (length == 3){
    buffer[x][y] = true;
    buffer[x+1][y-1] = true;
    buffer[x+1][y+1] = true;
    buffer[x+2][y-2] = true;
    buffer[x+2][y-1] = true;
    buffer[x+2][y] = true;
    buffer[x+2][y+1] = true;
    buffer[x+2][y+2] = true;

    }else {
    func(x, y, length/2);

    func(x+length/2 , y+length/2, length/2);

    func(x+length/2, y-length/2, length/2);
    }
    }
    int main() {
    cin.tie(NULL);


    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    for (int x= 0; x<n; x++){
    for (int y = 0; y< 2*n; y++){
    buffer[x][y] = false;
    }
    }
    func(0,n-1,n); // n =3 3, 5 n=6 1112

    for (int x= 0; x<n; x++){
    for (int y = 0; y< 2*n; y++){
    if (buffer[x][y]) cout << '*';
    else cout << ' ';
    }
    if (x != n-1) cout << '\n';
    }

    return 0;
    }


    '백준' 카테고리의 다른 글

    백준 1547번 C++ 풀이  (0) 2018.09.06
    백준 2455번 C++ 풀이  (0) 2018.08.29
    백준 1780번 C++ 풀이  (0) 2018.08.25
    백준 2490번 C++ 풀이  (0) 2018.08.24
    백준 3053번 풀이  (0) 2018.08.24
Designed by Tistory.