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

第100题一次AC,发贴留念

Posted by fbixiaozc135 at 2007-08-09 19:02:40 on Problem 1256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

class order
{
public:
	bool operator() (char x, char y)
	{
		if (x == y)
			return x < y;
		if (x == y + 32 || y == x + 32)
			return x < y;
		if (x >= 'A' && x <= 'Z')
		    x += 32; 
		if (y >= 'A' && y <= 'Z')
			y += 32;
		if (x != y)
			return x < y;
	}
};


int main()
{
	int m;
	cin >> m;
	string x;
	string y;

	for (int i = 0; i < m; ++i)
	{
		cin >> x;
		sort(x.begin(), x.end(), order());
		cout << x << endl;
		y = x;
		while(next_permutation(x.begin(), x.end(), order()))
		{
           if (y != x)
		     cout << x << endl;
		    y = x;
		}
	}

	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