- void rec_perm (string s, unsigned k)
- {
- if (k == s.length())
- cout << s << endl;
- else
- for (unsigned i = k; i < s.length(); i++)
- {
- swap (s [i], s [k]);
- rec_perm (s, k + 1);
- }
- }
- void permute (const string& s)
- {
- rec_perm (s, 0);
- }
- //该片段来自于http://www.codesnippet.cn/detail/2511201411062.html
来源: http://www.codesnippet.cn/detail/2511201411062.html