Cant print out pattern

#include <iostream>
using namespace std;
void pattern(int n, int shift);
int main()
{
int n;
cout << "Please enter an integer that is a power of two: ";
cin >> n;
if(n=2)
pattern(n, 0);
//else(n>2)
//{hey(n, 0);}
return 0;
}
void pattern(int n, int shift)
{
int i;
if(n == 2)//print(n/2,col)
{
for(i = 0; i <= shift; i++)
cout << " ";
cout << "a" << endl;
}else
pattern(n/2, shift);
pattern(n/2,shift);
pattern(n/2, shift + n/4);
for (i = 0; i < n; i++)
cout << "a ";


}
Hi all I am trying to print out this pattern but can't seem to print out the a pattern, the "-" is for illustration purposes. Please help me thankyou
a
aa
-a
aaaa
--a
--aa
---a-
aaaaaaaa
----a---
----aa--
-----a--
----aaaa
------a-
------aa
-------a
Last edited on
if(n=2) should probably be if(n==2)

What's the pattern rule? How do you get from one step to the next?
Topic archived. No new replies allowed.