UVa 1339,紫书P73,词频

时间:2023-03-08 22:17:00
UVa 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[],str2[];
int num1[],num2[];
while(scanf("%s%s",str1,str2)!=EOF)
{
int len = strlen(str1);
memset(num1,,sizeof(num1));
memset(num2,,sizeof(num2));
for(int i=;i<len;i++)
{
num1[str1[i]-'A'] ++;
num2[str2[i]-'A'] ++;
} sort(num1,num1+);
sort(num2,num2+);
bool flag = true;
for(int i=;i<;i++)
{
if(num1[i]!=num2[i]) {
flag = false;
break;
}
}
if(flag) puts("YES");
else puts("NO");
}
return ;
}