求助一道用递归产生非重复生成全子集组合排列(含重复数字时,生成不重复全子集组合排列)代码解释
01.#include <iostream> 02.using namespace std;
03.const int len=10;
04.int n;
05.int num;//不重复的实际个数
06.int mat[len];
07.int result[len];
08.int used[len];
09.void push(int varNum);
10.void solve(int cur_totalVar,int nextVar);
11.int main()
12.{
13. cin>>n;
14. num=0;
15. int var;
16. for (int i=0;i<n;i++)
17. {
18. cin>>var;
19. push(var);
20. }
21. solve(0,0);
22. system("pause");
23. return 1;
24.}
void push(int varNum)
35.{
36. for (int i=0;i<num;i++)
37. {
38. if (mat[i]==varNum)
39. {
40. used[i]++;
41. return;
42. }
43. }
44. mat[num]=varNum;
45. used[num]++;
46. num++;
47.}
void solve(int cur_totalVar,int nextVar)
62.{
63. for (int i=0;i<cur_totalVar;i++)
64. {
65. cout<<result[i];
66. }
67. cout<<endl;
68. for (int i=nextVar;i<num;i++)
69. {
70. if (used[i])
71. {
72. result[cur_totalVar]=mat[i];
73. used[i]--;
74. solve(cur_totalVar+1,i);
void solve函数代码解释,最好写过程