Skip to content

Instantly share code, notes, and snippets.

@goesang
Created November 8, 2015 11:43
Show Gist options
  • Save goesang/3f842e5f9c626a253b47 to your computer and use it in GitHub Desktop.
Save goesang/3f842e5f9c626a253b47 to your computer and use it in GitHub Desktop.
비트연산자를 이용한 부분집합 구하기
#include <stdio.h>
void main(void){
int i, j;
char arr[4] = { 'a', 'b', 'c', 'd' };
int n = 4;
for (i = 1; i < 1<<n; i++){
for (j = 0; j < n; j++){
if (i & (1 << j)){
printf("%c ", arr[j]);
}
}
printf("\n");
}
printf("%d",1<<n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment