全排列(cpp)

void process1(string str, int i){
    if(i == str.length()){
        cout << str << endl;
    }
    for(int j = i;j < str.length(); j++){
        swap(str[i], str[j]);
        process1(str, i+1);
    }
}

void printAllPermutations1(string str){
    process1(str, 0);
}
posted @ 2019-08-14 11:51  littledy  阅读(368)  评论(0编辑  收藏  举报