I'm trying to write a program in c that gets the number of elements of a set in the form: {1,2,3,...,n}
and then print all of its subsets, I have seen lots of solutions using arrays but I'm looking for a code without using arrays and just by defining some reversing functions.(1<=n<=20
)
for example if our input is 3 we will have this out put:
{ 1 2 3 }{ 1 2 }{ 1 3 }{ 1 }{ 2 3 }{ 2 }{ 3 }{ }
(The output must be in this alphabetic order.)
转载于:https://stackoverflow.com/questions/53059055/subsets-of-a-set-without-arrays-in-c