CPP
cpp
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
#include <iostream>
#include <cmath>
using namespace std;
int main() {
cout << "Variables count?" << endl;
int n, ** matr;
cin >> n;
int m = pow(2.0, n);
int *b = new int [n];
for(int i=0; i<m; ++i){
int j=i;
int id=n-1;
while(j > 0){
b[id] = j%2;
j /=2; id--;
}
for(int k=0; k<n; ++k){
cout << b[k] << " | " ;
}
cout << endl;
}
delete [] b;
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run