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 07151104107s at 2009-04-14 20:08:56 on Problem 2159
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#define max 100
int cmp ( const void *a , const void *b )
{return *(int *)a - *(int *)b;}

int main()
{
	char a[max],b[max];
	int i=0,flag=1,c[26],d[26];
	while(1)
	{
	gets(a);
	gets(b);
	memset(c,0,sizeof(c));
	memset(d,0,sizeof(d));
	while(a[i]!='\0')
	{
		c[a[i]-'A']++;
		d[b[i]-'A']++;
		i++;
	}

	qsort(c,26,sizeof(c[0]),cmp);
	qsort(d,26,sizeof(d[0]),cmp);
		for(i=0;i<26;i++)
		if(a[i]!=b[i])
		{
		flag=0;
		break;
		}

	if(flag)
		printf("YES\n");
	else
		printf("NO\n");
	}
	return 1;
}
		

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