标签:
题目的意思就是,输入两串字符串,看两个字符串上的字母是否能一一映射。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char tmp1[200], tmp2[200];
bool cmp (int a, int b) {
return a > b;
}
int main() {
while (scanf("%s%s", tmp1, tmp2) == 2) {
int sec[26] = {0}, original[26] = {0};
int len = strlen(tmp1);
for (int i = 0; i != len; ++i) {
++sec[tmp1[i] - ‘A‘];
++original[tmp2[i] - ‘A‘];
}
sort(sec, sec + 26, cmp);
sort(original, original + 26, cmp);
bool ok = true;
for (int i = 0; i != 26; ++i) {
if (original[i] != sec[i]) {
printf("NO\n");
ok = false;
break;
}
}
if (ok) printf("YES\n");
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/liangyongrui/p/4561439.html