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

Re:我写的和你结构比较像,对比看看

Posted by boy_lt at 2009-09-17 13:52:42 on Problem 2159
In Reply To:各位大牛帮忙看一下为什么错,感激不尽 Posted by:qlyzpqz at 2009-08-22 21:48:19
#include<iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
#define MAX 110
int a_1[26];
int a_2[26];
int len;
char s_1[MAX];
char s_2[MAX];
int CMP(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	int i;
	bool j;
	while(cin>>s_1>>s_2)
	{
		len=strlen(s_1);
		memset(a_1,0,sizeof(a_1));
		memset(a_1,0,sizeof(a_1));
		j=true;
		for(i=0;i<len;i++)
		{
			a_1[s_1[i]-'A']++;
			a_2[s_2[i]-'A']++;
		}
		qsort(a_1,26,sizeof(a_1[0]),CMP);
		qsort(a_2,26,sizeof(a_2[0]),CMP);
		for(i=0;i<26;i++)
			if(a_1[i]!=a_2[i])
				j=false;
		if(j)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
	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