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 tiger2008 at 2008-05-29 23:28:06 on Problem 2159
#include <stdio.h>


char    a[105], b[105];
int     count_a[26], count_b[26];//count_a[i]表示'A'+i的个数
int     result_a[26], result_b[26];//result_a[i]表示出现字母个数是i的 字母数

int main(int argc, char **argv)
{
        int             i, pos_a, pos_b;

        fgets(a, 105, stdin);
        fgets(b, 105, stdin);

        for(i = 0; a[i] != '\n'; i++){
                pos_a = a[i] - 'A';
                pos_b = b[i] - 'A';
                count_a[pos_a]++;
                count_b[pos_b]++;
        }

        for(i = 0; i < 26; i++){
                if(count_a[i] != 0){
                        result_a[count_a[i]-1]++;
                }
                if(count_b[i] != 0){
                        result_b[count_b[i]-1]++;
                }
        }

        for(i = 0; i < 26; i++){
                if(result_a[i] != result_b[i]){
                        printf("NO\n");
                        return 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