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:真的不好意思用STL水过的! STL就是好啊!

Posted by 20083331 at 2009-05-28 14:29:37 on Problem 1256
In Reply To:真的不好意思用STL水过的! STL就是好啊! Posted by:mightyvoice at 2009-05-27 12:35:47
同意,贴一下
#include <iostream>
#include <cstring>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
    int maps[125];
    int i,j;

    for(i=1;i<=26;i++)
        maps['A'+i-1]=2*i-1;
    for(i=1;i<=26;i++)
        maps['a'+i-1]=2*i;

    map<int,char> result;
    for(i=1,j=1;i<=51;i+=2,j++)
        result[i]='A'+j-1;
    for(i=2,j=1;i<=52;i+=2,j++)
        result[i]='a'+j-1;

    int n;
    cin>>n;
	char input[15];
	int record[15];
	while(n--)
	{
	    cin>>input;
	    int len=strlen(input);
	    for(i=0;i<len;i++)
	    {
                record[i]=maps[input[i]];
        }

	    sort(record,record+len);
	    for(i=0;i<len;i++)
                cout<<result[record[i]];
        cout<<endl;

		while(next_permutation(record,record+len))
		{
		     for(i=0;i<len;i++)
                cout<<result[record[i]];
            cout<<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