#include <stdio.h>

void printSolution(int* array, int* solution, int size)
{
	for(int i = 0; i < size; i++)
	{
		printf("{ ");
		for(int j = 0; j < size; j++)
		{
			if(solution[j] == i + 1)
			{
				printf("%d ", array[j]);
			}
		}
		printf("} ");
	}
	printf("\n");
}


void printPartitions(int* array, int* solution, int size, int step, int maximum)
{
	if(step == size) // no partitions left
	{
		printSolution(array, solution, size);
	}
	else
	{
        for(solution[step] = 1; solution[step] <= maximum; ++solution[step])
    	{
	        printPartitions(array, solution, size, step + 1, maximum);
	    }
	    printPartitions(array, solution, size, step + 1, maximum + 1);
	}
}

int main(int argc, char const *argv[])
{
	int array[] = {1, 2, 3, 4};
	int solution[4];

	printPartitions(array, solution, 4, 0, 0);

	return 0;
}