1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #include<iostream> #include<vector> #include<string>
using namespace std; vector<char> record = {'a', 'b', 'c'}; vector<vector<char>> result;
void Permutation2(vector<char> ¤t, int index) { if (index == record.size()) { result.push_back(current); return; } for (unsigned int i = index; i < record.size(); i++) { swap(record[i], record[index]); Permutation2(record, index + 1); swap(record[i], record[index]); } }
int main() { Permutation2(record, 0); return 0; }
|