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 shiming413 at 2005-10-20 16:53:09 on Problem 2629
帮忙看一下错哪了啊!
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int compare(const void*a,const void*b)
{
	if(*(char *)a>*(char *)b)
		return 1;
	if(*(char *)a<*(char *)b)
		return -1;
	return 0;
}
int main()
{
	int i,j,k;
	char a[1000],b[1000],c[1000];
	while(gets(a)&&gets(b))
	{
		qsort((void *)a,strlen(a),sizeof(a[0]),compare);
		qsort((void *)b,strlen(b),sizeof(b[0]),compare);
		k=0;
		for(i=strlen(a)-1;i>=0;i--)
		{
			j=strlen(b)-1;
			while(b[j]>=a[i])
			{
				if(a[i]==b[j])
				{
					c[k]=a[i];
					a[i]='\0';
					b[j]='\0';
					k++;
					break;
				}
				j--;
			}
			b[j+1]='\0';
		}
		c[k]='\0';
		qsort((void *)c,strlen(c),sizeof(c[0]),compare);
		printf("%s\n",c);
	}
	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