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

帮忙看下 感激不尽 我用的是查找各个字母的个数做的 为什么总是错啊

Posted by 435965344 at 2011-11-16 20:39:06 on Problem 2159
#include<stdio.h>
#include<string.h>
int main()
{
	char cput[100],cget[100];
	int counter1[26]={0},counter2[26]={0};
	int i,j=0;
	gets(cput);
	gets(cget);
	if(strlen(cput)!=strlen(cget))
		printf("NO\n");
	else
	{
		int x=strlen(cget);
	    for(i=0;i<x;i++)
		{
		    if(cput[i]!='A')
			{
		       cput[i]--;
			}
		    else
			{
		       cput[i]='Z';
			}
		}
	    for(i=0;i<x;i++)
		{
	 	    counter1[cget[i]-'A']++;
		}
	    for(i=0;i<x;i++)
		{
                    counter2[cput[i]-'A']++;
		}
	    for(i=0;i<26;i++)
		{
		    if(counter1[i]!=counter2[i])
			{
			   j++;
			}
		}
	    if(j==0)
		{
		    printf("YES\n");
		}
	    else
		{
		    printf("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