| ||||||||||
| 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 | |||||||||
WA的不行了……坚持、、、哪位大侠帮个忙啊帮忙看一下错哪了啊!
#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator