Created
December 30, 2019 17:45
-
-
Save 515hikaru/3f698f4e82fe836b2b718ffbb73f1443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
const int n = 5; | |
void rec(int *xs, int i) { | |
if (i == n) { | |
cout << "----------------" << endl; | |
for (int j = 0; j < n; j++) { | |
cout << xs[j] << " "; | |
} | |
cout << endl; | |
return; | |
} | |
xs[i] = 0; | |
rec(xs, i+1); | |
xs[i] = 1; | |
rec(xs, i+1); | |
} | |
void printCombination() { | |
int xs[n]; | |
for (int i = 0; i < n; i++) { | |
xs[i] = 0; | |
} | |
rec(xs, 0); | |
} | |
int main() { | |
printCombination(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment