字母全排列
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
string letters;
do
{
int count=0;
cout<<"Enter the sequence (quit to quit):";
cin>>letters;
cout<<"Permutations of"<<letters<<endl;
sort(letters.begin(),letters.end());
cout<<letters<<endl;
count++;
while(next_permutation(letters.begin(),letters.end()))
{
count++;
cout<<letters<<endl;
}
cout<<"上述字母组合一共有"<<count<<"种排法"<<endl;
}while(letters!="quit");
cout<<"Done.\n";
return 0;
}
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
string letters;
do
{
int count=0;
cout<<"Enter the sequence (quit to quit):";
cin>>letters;
cout<<"Permutations of"<<letters<<endl;
sort(letters.begin(),letters.end());
cout<<letters<<endl;
count++;
while(next_permutation(letters.begin(),letters.end()))
{
count++;
cout<<letters<<endl;
}
cout<<"上述字母组合一共有"<<count<<"种排法"<<endl;
}while(letters!="quit");
cout<<"Done.\n";
return 0;
}