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

郁闷中。。哪位大牛帮忙查查错啊,不甚感激。。。。

Posted by fusion at 2006-09-17 18:54:22 on Problem 1256
#include <stdio.h>
#include <algorithm>
#include <memory.h>


using namespace std;


char s[14];


int value(char ch)
{
	if (ch>='a') return 2*(ch-'a')+1;
	return 2*(ch-'A');
}


bool cmp(const char x,const char y)
{
	return value(x)<=value(y);
}


void read()
{
	int t;
	scanf("%d",&t);
	while (t--)
	{
		memset(s,0,sizeof(s));
		scanf("%s",s);
		sort(s,s+int(strlen(s)),cmp);
		do
		{
			printf("%s\n",s);
		}while (next_permutation(s,s+int(strlen(s))));
	}
}


int main()
{
	read();
	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