Blame view

P62467_en/S001-AC.cc 562 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 lowerLimit, int upperLimit, int n)
{
	array[(upperLimit+lowerLimit)/2].append(n,'*');
	if(lowerLimit == upperLimit)
	{
		return;
	}
	bars(array,lowerLimit,(upperLimit+lowerLimit)/2 - 1,n-1);
	bars(array,(upperLimit+lowerLimit)/2 +1,upperLimit,n-1);
}

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