首页 > 代码库 > UAa 1339,紫书P73,词频

UAa 1339,紫书P73,词频

题目链接:https://uva.onlinejudge.org/external/13/1339.pdf

紫书P73

解题报告:

#include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std;int main(){    //freopen("input.txt","r",stdin);    char str1[110],str2[110];    int num1[30],num2[30];    while(scanf("%s%s",str1,str2)!=EOF)    {        int len = strlen(str1);        memset(num1,0,sizeof(num1));        memset(num2,0,sizeof(num2));        for(int i=0;i<len;i++)        {            num1[str1[i]-A] ++;            num2[str2[i]-A] ++;        }        sort(num1,num1+26);        sort(num2,num2+26);        bool flag = true;        for(int i=0;i<26;i++)        {            if(num1[i]!=num2[i]) {                flag = false;                break;            }        }        if(flag) puts("YES");        else puts("NO");    }    return 0;}

 

UAa 1339,紫书P73,词频