标签:
题目链接:http://poj.org/problem?id=1256
解题报告:
1、sort函数是按照ASC11码排序,而这里是按照 ‘A‘<‘a‘<‘B‘<‘b‘<...<‘Z‘<‘z‘排序。
#include <iostream> #include <algorithm> #include <string> using namespace std; bool cmp(char a,char b) { char m=tolower(a); char n=tolower(b); if(m==n) return a<b; else return m<n; } int main() { int t; cin>>t; while(t--) { string s; cin>>s; sort(s.begin(),s.end(),cmp); do { cout<<s<<endl; }while(next_permutation(s.begin(),s.end(),cmp)); } return 0; }
标签:
原文地址:http://www.cnblogs.com/TreeDream/p/5304153.html