带重复元素的数组全排列问题。c++实现

#include using namespace std; void swap(int &a, int &b) { int temp = a; a = b; b = temp; } void perm(int list[], int low, int high) { if (low == high) { for (int i = 0; i <= low; i++) cout << list[i]; cout << endl; } else { for (int i = low; i <= high; i++) { if ((list[i] == list[low])&(i != low)) { continue; } swap(list[i], list[low]); perm(list, low + 1, high); swap(list[i], list[low]); } } } int main() { int list[] = {1,2,3}; perm(list, 0, 2); system("pause"); return 0; }

【带重复元素的数组全排列问题。c++实现】

    推荐阅读