Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:写了一个更短小精悍的代码

Posted by hehexiaobai at 2010-08-21 09:27:42 on Problem 1256
In Reply To:写了一个更短小精悍的代码 Posted by:fuliang at 2009-05-05 00:25:44
哥也帖一个

#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
bool cmp(const char a, const char b)
{
    if( (a|32)==(b|32) ) return a<b; 
    else return (a|32)<( b|32);
}
int main()
{
    int t;
    cin>>t;
    string str;
    while(t--)
    {
              cin>>str;
              sort(&str[0],&str[str.size()],cmp);
              cout<<str<<endl;
              while(next_permutation(&str[0], &str[str.size()],cmp))
                                              cout<<str<<endl;
    }
   
    return 0;
}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator