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

Re:我有用STL函数,不过还是WA,希望高手给我一些强的测试数据,多谢了

Posted by 810974380 at 2009-08-28 15:44:56 on Problem 1256
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:
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