Enter a set for the question description, and you need to generate all the combinations that can be obtained from the set. Example: If the input set is {1, 2}, the combinations that need to be generated include {1}, {1, 2}, {2 }. This topic is similar to the full arrangement of the generated set and is also a classic problem. Here we use the recursive method to solve this problem. In the face of such a problem, we need to analyze it carefully. The question requires that all the combinations of a set be generated, that is, all the combinations that can be composed of elements in the Set be generated. The obvious idea is to traverse the set. We can use loops or recursion to traverse a set. To solve this problem, it is very convenient to use recursive thinking. Suppose our set is {1, 2, 3}. We will scan the elements of the set from scratch. The first element is 1. For this element, we can place it in the combination set, and then select it in the remaining set; or we can leave it in the combination set, select the elements in the remaining set and put them in the combination set. In general, assume that our set has n elements and requires a combination of m elements. We can scan every element. For this element, we can place it in the combination set, and then select the -1 element in the remaining n-1 elements. We can also leave this element in the set, select m elements from the n-1 elements. This is already a clear idea of recursion. The specific code is as follows. Code [cpp] void combination (char * src, int num, vector <char> & result) {if (num = 0) {vector <char> :: iterator iter = result. begin (); for (; iter <result. end (); iter ++) {printf ("% c", * iter) ;}printf ("\ n"); return ;} if (* src = '\ 0') return; result. push_back (* src); combination (src + 1, num-1, result); result. pop_back (); combination (src + 1, num, result);} void all_sub_set (char * src) {assert (src); if (! Src) return; int I = 0; int len = strlen (src); vector <char> result; for (I = 1; I <= len; I ++) {combination (src, I, result) ;}} the summary recursively generates all the combinations of the Set, which is a test of a programmer's basic programming skills. This problem is different from that of generating a set subset of Gray Code in sequence. It is a classic solution.