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 lollipopcat at 2008-09-21 20:25:05 on Problem 2159
int main(){
	string s1,s2;
	int i,j;
	while(cin>>s1>>s2){
	int letter1[26];
	int letter2[26];
	memset (letter1,0,sizeof(letter1));
	memset (letter2,0,sizeof(letter2));

	int len1=s1.length(),len2=s2.length();
	if(len1!=len2) printf("NO\n");
	else{
		for(i=0;i<len1;i++){
			letter1[s1[i]-'A']++;
			letter2[s1[i]-'A']++;
		}
	}
	len1=0;
	len2=0;
	for(i=0;i<26;i++){
		if(letter1[i]){
			len1++;
			for(j=0;j<26;j++){
				if(letter1[i]==letter2[j]){len2++;letter2[j]=0;break;}
			}
		}
	}
	if(len1==len2) 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