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啊.高手帮忙看看.mail我,THX

Posted by bluefoam at 2005-05-31 23:55:28 on Problem 2159
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int cmp(const void *a,const void *b){
	return(*(int *)a-*(int *)b);
}
int main(){
	//freopen("test.in","r",stdin);
	char temp[110];
	int length,s1[26],s2[26],i,j,change;
	while(scanf("%s",&temp)!=EOF){
		for(i=0;i<26;i++) s1[i]=s2[i]=0;
		length=strlen(temp);
		for(i=0;i<strlen(temp);i++)	s1[temp[i]-'A']++;
		scanf("%s",&temp);
		length=strlen(temp);
		for(i=0;i<strlen(temp);i++)	s2[temp[i]-'A']++;
		qsort(s1,26,sizeof(s1[0]),cmp);
		qsort(s2,26,sizeof(s2[0]),cmp);
		change=1;
		for(j=0;j<26;j++){	if(s1[j]!=s2[j]){	change=0;break;	}}
		if(change==0) printf("NO\n");
		else printf("Yes\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