poj1256(全排列)

来源:互联网 发布:软件著作权一般几个人 编辑:程序博客网 时间:2024/06/05 16:51

http://poj.org/problem?id=1256

#include<iostream>#include<algorithm>#include<string>#include<cstdio>using namespace std;bool comp(char a, char b){if(tolower(a)==tolower(b)){return a < b;}elsereturn tolower(a)<tolower(b);}int main(){//freopen("in.txt", "r", stdin);int n;string str;cin>>n;while(n--){cin>>str;sort(str.begin(), str.end(), comp);do{cout<<str<<endl;}while(next_permutation(str.begin(), str.end(), comp));}return 0;}


0 0
原创粉丝点击