Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstring>
- #include <algorithm>
- #include <stack>
- using namespace std;
- int main() {
- int n = 3;
- for(int bitmask = 0; bitmask < (1 << n); bitmask++) { // (1 << n) = power(2, n)
- for(int bit = 0; bit < n; bit++) {
- if(bitmask & (1 << bit)) {
- cout << bit + 1 << " " ;
- }
- }
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement