【思路】:通过cnt数组计数,然后比对。
【AC代码】:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>
using namespace std;
#define MAX 80+5
int main()
{
freopen("in.txt", "r", stdin);
int cnt_a[26], cnt_b[26], i = 0;
char str_1[MAX], str_2[MAX];
//input
cin >> str_1 >> str_2;
memset(cnt_a, 0, sizeof(cnt_a));
memset(cnt_b, 0, sizeof(cnt_b));
//cnt
for (i = 0; i < strlen(str_1); i++)
{
if (str_1[i] >= 'a' && str_1[i] <= 'z')
cnt_a[str_1[i]-'a']++;
else if (str_1[i] >= 'A' && str_1[i] <= 'Z')
cnt_a[str_1[i]-'A']++;
}
for (i = 0; i < strlen(str_2); i++)
{
if (str_2[i] >= 'a' && str_2[i] <= 'z')
cnt_b[str_2[i]-'a']++;
else if (str_2[i] >= 'A' && str_2[i] <= 'Z')
cnt_b[str_2[i]-'A']++;
}
//judge
for (i = 0; i < 26; i++)
{
if (cnt_a[i] != cnt_b[i])
{
cout << "N";
return 0;
}
}
cout << "Y";
}