Blame view

P10694_en/S001-AC.cc 423 Bytes
Imanol-Mikel Barba Sabariego authored
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
29
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

void bars(string* array, int pos, int n)
{
	array[pos].append(n,'*');
	if(n == 1)
	{
		return;
	}
	bars(array,pos+1,--n);
	bars(array,pos+pow(2,n),n);
}

int main()
{
	int n;
	cin >> n;
	string* array = new string[(int)(pow(2,n) - 1)];
	bars(array,0,n);
	for(int i = (pow(2,n) - 2); i > -1; i--)
	{
		cout << array[i] << endl;
	}
	return 0;
}