1 vector <string> a;
2 a={"0","1"};
3 int i, j;
4 for (i = 2; i < (1<<n); i = i<<1)
5 {
6 for (j = i-1 ; j >= 0 ; j--)
7 a.push_back(a[j]);
8 for (j = 0 ; j < i ; j++)
9 a[j] = "0" + a[j];
10 for (j = i ; j < 2*i ; j++)
11 a[j] = "1" + a[j];
12 }
13 for (i = 0 ; i < a.size() ; i++ )
14 cout << a[i] << " ";