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

各位大牛帮忙看一下为什么错,感激不尽

Posted by qlyzpqz at 2009-08-22 21:48:19 on Problem 2159
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void * arg1,const void * arg2)
{
	int * a,* b;
	a=(int *)arg1;
	b=(int *)arg2;
	return (*b)-(*a);
}
int main()
{
	char a[100],b[100];
	int lena,i,anum[27],bnum[27],flag;
	memset(anum,0,sizeof(anum));
	memset(bnum,0,sizeof(bnum));
	gets(a);
	gets(b);
	lena=strlen(a);
	for(i=0;i<lena;i++) {
		anum[a[i]-'A'+1]++;
		bnum[b[i]-'A'+1]++;
	}
	qsort((void *)(&anum[1]),26,sizeof(anum[0]),cmp);
	qsort((void *)(&bnum[1]),26,sizeof(bnum[0]),cmp);
	flag=1;
	for(i=1;i<=26 && flag;i++) {
		if(anum[i]!=bnum[i])
			flag=0;
	}
	if(flag==1)
		printf("YES\n");
	else
		printf("NO\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