#include <stdio.h>

int n;
int a[100];//测试100个元素以内 
int count;
int f(int k)
{
	if (!k)
	{
		int i;
		printf("{");
		for	(i = 1; i <= n; ++i)
		{
			if (a[i])
			{
				printf("%d", i);
			}
		}
		printf("}\n");
		++count;
	}
	else
	{
		int i;
		for (i = 0; i < 2; ++i)
		{
			a[k] = i;
			f(k - 1);
		}
	}
}

int main()
{
	printf("元素个数:");
	scanf("%d", &n);
	f(n);
	printf("共%d个子集!", count);
	return 0;
}
========================================Talk is cheap, show me the code=======================================