Created
April 10, 2019 17:15
-
-
Save 2p31-1/6faa4f99e05b26b4971e865bbf077e0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main() { | |
int a; | |
cin >> a; | |
int phase = 0; | |
vector<bool>star; | |
for (int x = 0; x < a*2+10; x++) { | |
star.push_back(0); | |
} | |
star[0] = 1; | |
for (int i = 0; i < a; i++) { | |
for (int p = 0; p < a - i; p++) { | |
cout << " "; | |
} | |
for (int p = 0; i != 0&& p < i * 2 + 1;) { | |
if (star[p]) { | |
if (!star[p + 2]) { | |
star[p + 2] = 1; | |
p += 6; | |
} | |
else { | |
if (!star[p + 1]) { | |
star[p + 1] = 1; | |
star[p + 3] = 1; | |
star[p + 4] = 1; | |
p += 6; | |
} | |
else { | |
int z = p; | |
for (int q = 6; q+p < a*2+1; q+=6) { | |
if (star[p+q])z = q+p; | |
else break; | |
} | |
for (int n = p + 1; n < z + 6; n++) { | |
star[n] = 0; | |
} | |
if(z+6<a*2+1)star[z + 6] = 1; | |
if(z+12<a*2+1)p = z + 12; | |
else break; | |
} | |
} | |
} | |
else { | |
p += 6; | |
} | |
} | |
for (int p = 0; p < i * 2 + 1; p++) { | |
if (star[p])cout << "*"; | |
else cout << " "; | |
} | |
cout << endl; | |
} | |
} | |
/* | |
10000 | |
10100 | |
11111 3 6*1-1 | |
10000010000 0 6 | |
10100010100 | |
11111011111 11 = 6*2-1 | |
10000000000010000000000 0 12 | |
10100000000010100000000 | |
11111000000011111000000 | |
10000010000010000010000 | |
10100010100010100010100 | |
11111011111011111011111 23 = 6*4-1 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment