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

测试数据都对,就是AC不了。望高手指点!

Posted by 123456789987654321 at 2008-09-16 18:31:08 on Problem 1256
#include <iostream>
#include <algorithm> 
using namespace std;

void sort(char * a,char * b,int len)//将排序结果放入b中
{   
    int	i,j,k=0;
	int x[26],y[26];
	memset(x,0,sizeof(x));
	memset(y,0,sizeof(y));

	for(i=0;i<len;i++)
	{
		if(a[i]>='A'&&a[i]<='Z')
			x[a[i]-65]++;
		if(a[i]>='a'&&a[i]<='z')
			y[a[i]-97]++;
	}
	for(i=0;i<26;i++)
	{
		if(x[i]!=0)
		{
			for(j=1;j<=x[i];j++)
			 b[k++]=char(i+65);
		}
	    if(y[i]!=0)
		{
			for(j=1;j<=y[i];j++)
			 b[k++]=char(i+97);
		}
	}
}

int main()
{   

	//freopen("in.txt","r",stdin);
	int len,i,m;
	char str[15],b[15];
	scanf("%d",&m);
	while(m--)
	{
       scanf("%s",str);
       len=strlen(str);
	   sort(str,b,len);
       for(i=0;i<len;i++)
	   {
              printf("%c",b[i]); //输出原字符串作为第一个排列
	   }
        printf("\n");
      
	   while(next_permutation(b,b+len)) //
           {
                    for(i=0;i<len;i++)
                          printf("%c",b[i]);
                   printf("\n");
            }


 }
	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