STL 全排列

全排列STL 

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
    	char s[100];
    	cin >> s;
    	int l=strlen(s);
    	sort(s,s+l);
    	do{
      	  	for (int i = 0; i < l;i++) cout << s[i];
      	  	cout << endl; 
   		}while(next_permutation(s,s+l));
		cout << endl;
	}
    return 0;
}

猜你喜欢

转载自blog.csdn.net/lgz0921/article/details/84641188