Created
November 8, 2015 11:43
-
-
Save goesang/3f842e5f9c626a253b47 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 <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