#include "stdafx.h" #include <string> #include <algorithm> #include <iostream> void func(const char *str_in) { std::string str(str_in); std::sort(str.begin(),str.end()); do { std::cout<<str<<std::endl; }while (std::next_permutation(str.begin(),str.end())); } int _tmain(int argc, _TCHAR* argv[]) { func("cab"); return 0; }