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 tzj115 at 2007-07-09 18:16:38 on Problem 2159
In Reply To:Re:为什么总是WA,我的理解有误吗? Posted by:Hzj_jie at 2005-11-19 00:30:12
# include <iostream.h>
# include <stdlib.h>
# include <stdio.h>
# include <string.h>

int cmp(const void * a,const void * b)
{
	return *( char*)a-*(char *)b;
}

char s1[110];
char s2[110];

int done(char * a,char * b,int l1,int l2)
{
	int jian=a[0]-b[0];
	if(l1!=l2)
		return 0;
	for(int i=1;i<l1;i++)
	{
		if(a[i]-b[i]!=jian)
			return 0;
	}
	return 1;
}

int main()
{
	int len1=0,len2=0;
	cin>>s1;
	cin>>s2;
	len1=strlen(s1);
	len2=strlen(s2);
	qsort(s1,len1,sizeof(char),cmp);
	qsort(s2,len2,sizeof(char),cmp);
	cout<<s1<<"\n";
	cout<<s2<<"\n";
	if(done(s1,s2,len1,len2))
		cout<<"YES\n";
	else
		cout<<"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