📜  查找排列 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:51.086000             🧑  作者: Mango

代码示例2
void find_permutations(vector &array, size_t index, vector current_perm, vector> &res){
    if(index == array.size()) 
        res.push_back(current_perm);
    else{
        for(size_t i = 0; i <= current_perm.size(); ++i){
            vector new_perm(current_perm.begin(), current_perm.end());
            new_perm.insert(new_perm.begin()+i, array[index]);
            find_permutations(array, index+1, new_perm, res);
        }
    }
}