| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
帮忙看下哪里错了.thx#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator