느낀 및 명 ¶
.. 것과 가로 력는 부 는다. ( 력 결기 때문.)
또 드를 다는 명목 로 나 따. (귀.ㅎ)
.. 27 동 깨더 겠... 만들 며, 그래 가 다.
고리 1과 0로 를 , 겨가면 모든 경 를 는 것다.
또 를 들 7개 경는 1개때, 2개때, ... 7개때 런로 나 다.
배 를 보 명 부듯 덧붙다.
를 들 9Set 면..
배1 - 1,2,3,4,5,6,7,8,9
배2 - 1 0 0 0 0 0 0 0 0
렇게 1 경 력다. 례
배2 - 0 1 0 0 0 0 0 0 0
배2 - 0 0 1 0 0 0 0 0 0
배2 - 0 0 0 1 0 0 0 0 0
배2 - 0 0 0 0 1 0 0 0 0
배2 - 0 0 0 0 0 1 0 0 0
배2 - 0 0 0 0 0 0 1 0 0
배2 - 0 0 0 0 0 0 0 1 0
배2 - 0 0 0 0 0 0 0 0 1
런 게 된다.
그 2개로 가 ...또 드를 다는 명목 로 나 따. (귀.ㅎ)
.. 27 동 깨더 겠... 만들 며, 그래 가 다.
고리 1과 0로 를 , 겨가면 모든 경 를 는 것다.
또 를 들 7개 경는 1개때, 2개때, ... 7개때 런로 나 다.
리는 () | |
9개 | 0.078 |
10개 | 0.172 |
11개 | 0.375 |
12개 | 0.781 |
를 들 9Set 면..
배1 - 1,2,3,4,5,6,7,8,9
배2 - 1 0 0 0 0 0 0 0 0
렇게 1 경 력다. 례
배2 - 0 1 0 0 0 0 0 0 0
배2 - 0 0 1 0 0 0 0 0 0
배2 - 0 0 0 1 0 0 0 0 0
배2 - 0 0 0 0 1 0 0 0 0
배2 - 0 0 0 0 0 1 0 0 0
배2 - 0 0 0 0 0 0 1 0 0
배2 - 0 0 0 0 0 0 0 1 0
배2 - 0 0 0 0 0 0 0 0 1
런 게 된다.
배2 - 1 1 0 0 0 0 0 0 0
배2 - 1 0 1 0 0 0 0 0 0
배2 - 1 0 0 1 0 0 0 0 0
배2 - 1 0 0 0 1 0 0 0 0
배2 - 1 0 0 0 0 1 0 0 0
배2 - 1 0 0 0 0 0 1 0 0
배2 - 1 0 0 0 0 0 0 1 0
배2 - 1 0 0 0 0 0 0 0 1
배2 - 0 1 1 0 0 0 0 0 0
배2 - 0 1 0 1 0 0 0 0 0
배2 - 0 1 0 0 1 0 0 0 0
배2 - 0 1 0 0 0 1 0 0 0
배2 - 0 1 0 0 0 0 1 0 0
배2 - 0 1 0 0 0 0 0 1 0
배2 - 0 1 0 0 0 0 0 0 1
배2 - 0 0 1 1 0 0 0 0 0
.
.
(략)
런로 모든 경 를 낸다.^^
문나 부 대는 글 남겨.^^*
배2 - 1 0 1 0 0 0 0 0 0
배2 - 1 0 0 1 0 0 0 0 0
배2 - 1 0 0 0 1 0 0 0 0
배2 - 1 0 0 0 0 1 0 0 0
배2 - 1 0 0 0 0 0 1 0 0
배2 - 1 0 0 0 0 0 0 1 0
배2 - 1 0 0 0 0 0 0 0 1
배2 - 0 1 1 0 0 0 0 0 0
배2 - 0 1 0 1 0 0 0 0 0
배2 - 0 1 0 0 1 0 0 0 0
배2 - 0 1 0 0 0 1 0 0 0
배2 - 0 1 0 0 0 0 1 0 0
배2 - 0 1 0 0 0 0 0 1 0
배2 - 0 1 0 0 0 0 0 0 1
배2 - 0 0 1 1 0 0 0 0 0
.
.
(략)
런로 모든 경 를 낸다.^^
문나 부 대는 글 남겨.^^*
¶
~cpp #include <time.h> #include <stdio.h> #include <iostream> int* input_and_return_number(int*); void process(int*, int); int main() { int time_in; // 기 . ///// int gaesu; int *temp_gaesu=&gaesu; int *numbers=input_and_return_number(&gaesu); ///// time_in = clock(); // 기 력다. process(numbers,gaesu); free(numbers); printf("CPU CLOCKS = %d\n", clock() - time_in); // 끝났때 - 기 = 로그램 return 0; // 로그램 료. } int* input_and_return_number(int *number_gaesu) { printf("력 개는?>>"); fflush(stdin); scanf ("%d",number_gaesu); int *numbers=(int*)malloc(sizeof(int)*(*number_gaesu)); for (register int i=0; i<*number_gaesu; ++i) { printf("%d 를 력.>>",i+1); fflush(stdin); scanf("%d",numbers+i); } return numbers; } void process(int *numbers, int gaesu) { int *temp_where=(int*)malloc(sizeof(int)*gaesu); for (register int temp_gaesu=1; temp_gaesu<=gaesu; ++temp_gaesu) { int bun_ja=1; int bun_mo=1; for (register int i=0; i<temp_gaesu; ++i) { bun_ja*=gaesu-i; bun_mo*=i+1; } int combination=bun_ja/bun_mo; for (register int i=0; i<gaesu; ++i) { if (i<temp_gaesu) temp_where[i]=1; else temp_where[i]=0; } for (register int i=0; i<combination; ++i) { printf("{"); int end=gaesu-1; for (register int j=0; j<gaesu; ++j) { if(1==temp_where[j]) printf(" %d ",numbers[j]); } printf("} "); int find_last=end; for (; find_last>=0; --find_last) { if (1==temp_where[find_last]) break; } if (find_last==end) { int gaesu_of_one=0; int find_zero=0; for (register int j=end; j>=0; --j) { if (0==temp_where[j]) find_zero=1; else { temp_where[j]=0; if (0==find_zero) ++gaesu_of_one; else { for (register int k=j+1; k<j+2+gaesu_of_one; ++k ) temp_where[k]=1; break; } } } } else { temp_where[find_last]=0; temp_where[find_last+1]=1; } } } free(temp_where); }