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 xiefenglong at 2009-09-21 22:41:45 on Problem 2159
#include <iostream>

using namespace std;

int main()
{
    char a[150],b[150];
    int i;
    int temp1=0,temp2=0;
    int RESULT_A[26],RESULT_B[26];
    cin.getline(a,150,'\n');
    cin.getline(b,150,'\n');

    for(i=0;i<26;i++)
    {
        RESULT_A[i]=RESULT_B[i]=0;
    }
    for(i=0;(a[i]!='\0')&&(b[i]!='\0');i++)
    {
        RESULT_B[b[i]-'A']++;
        RESULT_A[a[i]-'A']++;
}

    for(i=0;i<26;i++)
    {




        if(RESULT_A[i]!=RESULT_B[i]&&RESULT_A[i]!=0&&RESULT_B[i]!=0)
           {
                cout<<"NO"<<endl;
         return 0;


        }
        if(RESULT_A[i]!=RESULT_B[i]&&RESULT_B[i]==0)
            temp1+=RESULT_A[i];
             if(RESULT_A[i]!=RESULT_B[i]&&RESULT_A[i]==0)
            temp2+=RESULT_B[i];
                }
    if(temp1!=temp2)
    {
         cout<<"NO"<<endl;
         return 0;
    }




    cout<<"YES"<<endl;
    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