Skip to content

Instantly share code, notes, and snippets.

@515hikaru
Created December 30, 2019 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 515hikaru/3f698f4e82fe836b2b718ffbb73f1443 to your computer and use it in GitHub Desktop.
Save 515hikaru/3f698f4e82fe836b2b718ffbb73f1443 to your computer and use it in GitHub Desktop.
#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