Skip to content

Instantly share code, notes, and snippets.

@huiyiqun
Created February 13, 2015 15:52
Show Gist options
  • Save huiyiqun/3f061c3c120d1b23a7d0 to your computer and use it in GitHub Desktop.
Save huiyiqun/3f061c3c120d1b23a7d0 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define WIDTH 6
void output(int value, int depth) {
if (depth == 0)
return;
output(value >> 1, depth-1);
printf("%d", value & 1);
}
int main() {
int n = (1 << WIDTH);
for (int i = 0; i < n; i++) {
output(i, WIDTH);
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment