| ||||||||||
| 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 | |||||||||
Re:我有用STL函数,不过还是WA,希望高手给我一些强的测试数据,多谢了In Reply To:我有用STL函数,不过还是WA,希望高手给我一些强的测试数据,多谢了 Posted by:Sukileen at 2009-08-16 14:54:21 >
用 STL 切记 写个正确的 cmp 函数~
另外 用next_permutation 时在里面要加上 cmp 函数~
Problem: 1256 User: 810974380
Memory: 188K Time: 47MS
Language: C++ Result: Accepted
Source Code
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<algorithm>
using namespace std;
char st[15];unsigned int len;
int t;
bool cmp(char a, char b) {
return tolower(a) == tolower(b) ? a < b : tolower(a) < tolower(b);
}
int main()
{
scanf("%d",&t);
getchar();
while(t--)
{
gets(st);
len=strlen(st);
sort(st,st+len,cmp);
while(1)
{
puts(st);
if(!next_permutation(st,st+len,cmp)) break;
}
}
system("pause");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator