递归练习
全排列问题:
STL中的一个函数next_permutaion,直接求到第一个不按升序排列的序列。
STL中,函数next_permutation,用于求出下一个排列组合,返回值是bool型,函数prev_permutation,用于求出上一个排列组合,两者都是用来计算排列组合的函数。
#include <iostream>
#include<iostream>
#include <algorithm>
#include <cstring>
using namespace std;
char str[20];
int main()
{
cin >> str;
do{
cout << str << endl;
} while (next_permutation(str, str + strlen(str)));
return 0;
}