static void makePair(vector<int>& part1, vector<char>& part2) { // 0. check parts if (part1.size() != part2.size()) { cout << "no same count" << endl; return; } // 1. build permutation of part1 int cnt = (int)part1.size(); int num = 0; sort(part1.begin(), part1.end()); do { cout << ++num << "th pairs" << endl; for (int i = 0; i < cnt; ++i) { // 2. make pair from part2 cout << " " << part1[i] << " - " << part2[i] << endl; } } while(next_permutation(part1.begin(), part1.end())); }