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

这个输入是YES 吗?我认为程序不对啊。

Posted by hebeimoumoumou at 2011-04-02 22:09:19 on Problem 2159
#include<iostream>
using namespace std;
#include<cstring>
char a[2][102];
int main()
{
    int i,j,l;
    int n[2][26]={0};
    scanf("%s",a);
    scanf("%s",a+1);
    l=strlen(a[0]);
    for(i=0;i<l;i++)
    {
        n[0][a[0][i]-'A']++;
        n[1][a[1][i]-'A']++;
    }
    for(i=0;i<26;i++)
    {
        for(j=0;j<26;j++)
        {
            if(n[0][i]==n[1][j])
            {
               n[1][j]=0;
                break;
            }
        }
        if(j==26)
        {
            printf("NO\n");
            break;
        }
    }
    if(i==26)
    printf("YES\n");
    return 0;
}

上面是AC的程序。。但我认为输入是ABBCCC
                            ABBCCC 的时候程序时输出YES的  ,可这明显不对啊。。

我是不是没理解对 ,,帮忙解释下啊

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