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

谁能帮忙出几组数据,感觉都过得了,还是WA

Posted by labor at 2008-11-07 17:44:16 on Problem 1731
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int cmp(const void *a,const void *b)
{return *(char *)a-*(char *)b;}
void main()
{
	char a[202],change;
	int i,j;
	int l,c;
	gets(a);
	//scanf("%s",a);
	l=strlen(a);
	qsort(a,l,sizeof(a[0]),cmp);
	a[l]='\0';
	printf("%s\n",a);
	i=l-1;c=1;
	while(1)
	{
		for(j=i;j>=0;j--)
		{
			if(a[i]>a[j])
			{
				change=a[i];
				a[i]=a[j];
				a[j]=change;
				break;
			}
		}
		if(l-1-c==-1)
			break;
		if(j<0)
		{
			i=l-1-c;
			c++;
			continue;
		}
		c=1;
		i=l-1;
		qsort(a+j+1,l-j-1,sizeof(a[0]),cmp);
		a[l]='\0';
		printf("%s\n",a);
	}
}

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