U E D R , A S I H C RSS

수학의정석/집합의연산/조현태

.. 포함하 . ( .)
. (.ㅎ)
.. 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 ...
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
.
.
()
.^^
.^^*



~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);
}

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:15
Processing time 0.0245 sec