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

帮忙看下哪里错了.thx

Posted by hongtaos at 2006-04-04 13:41:38 on Problem 1256
#include <iostream>
#include <algorithm>
using namespace std;
int mycompare(char a,char b);
int compare(const void* arg1, const void* arg2);
bool per_compare(char arg1, char arg2);
int main()
{
	int nCase;
	cin>>nCase;
	cin.get();
	int i=0;
	char str[15];
	for (; i<nCase; ++i) 
	{
		memset(str,0,sizeof(str));
		gets(str);
		//qsort(str,strlen(str),1,compare);
		sort(str,str+strlen(str),mycompare);

		//int count=0;
		do {
			cout<<str<<endl;
		//	count++;
		} while(next_permutation(str,str+strlen(str),per_compare));
		//cout<<"count: "<<count<<endl;
		
	}
	return 0;
}

int compare(const void* arg1, const void* arg2)
{
	char a=*(char*)arg1;
	char b=*(char*)arg2;
	char c=tolower(a);
	char d=tolower(b);
	if (c==d) {
		return a>b;
	}
	return c>d;
}

bool per_compare(char arg1, char arg2)
{
	char c=tolower(arg1);
	char d=tolower(arg2);
	if (c==d) {
		return arg1<arg2;
	}
	return c<d;
}
int mycompare(char a,char b)
{
	char c,d;
	c=tolower(a);
	d=tolower(b);

	if(c==d)
		return (a<b);

	return c<d;
}

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