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 20091876 at 2010-02-09 21:18:03 on Problem 2159
#include<stdio.h>
#include<string.h>
sorting(char *a,int n)
{
	int i,l,max;char temp;
	for(i=0;i<n-1;i++)
	{
		max=i;
		for(l=i+1;l<n;l++)	if(a[max]<a[l]) max=l;
        temp=a[max];
		a[max]=a[i];
		a[i]=temp;
	}
}
main()
{
	char f[110],g[110];int k,r,n1,n2;
	while(scanf("%s\n%s",f,g)!=EOF)
	{
		n1=strlen(f);
		n2=strlen(g);
		sorting(f,n1);
		sorting(g,n2);
		r=g[0]-f[0];
		for(k=1;k<n1;k++)
		{
			if(f[k]+r!=g[k]) break;
		}
		if(k==n1) printf("YES\n");
		else printf("NO\n");
	}
}

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