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:这段代码很简单的,就是WA,哪位大牛指点下~

Posted by iYao at 2009-07-19 16:00:53 on Problem 2159
In Reply To:这段代码很简单的,就是WA,哪位大牛指点下~ Posted by:iYao at 2009-07-19 13:47:33
#include <stdio.h>
#include <string.h>

int main ()
{
	int i, j;
	char a[101], b[101];
	scanf ("%s%s", a, b);
	if (strlen(a) != strlen(b))
		printf ("NO\n");
	for (i = 0; a[i]!='\0'; i++)
	{
		if (a[i] == 'a')
			a[i] = 'z';
		else
			a[i] = a[i]-1;
	}
	for (i = 0; a[i]!='\0'; i++)
		for (j = 0; b[j]!='\0'; j++)
		{
			if (a[i] == b[j])
			{
				b[j] = 1;
				break;
			}
			else if (b[j+1] == '\0')
			{
				printf ("NO\n");
				return 0;
			}
		}
	if (a[i] == '\0')
		printf ("YES\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