摘要:
//输入待排数组,cur=0,end为数组长度void perm(int a[], int cur, int end){ int i = cur; if (cur == end) { for (int j = 0; j < end; j++) { cout << a[j] << " "; } cout << endl; } while(i < end) { swap(a[i],a[cur]);//把a[i]拿出来放在前面,排列剩下的 perm(a, cur + 1, end); swap(a[i], a[cur]);//排列好 阅读全文