UVA - 1339 Ancient Cipher
程序员文章站
2022-04-02 10:06:08
...
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define maxn 105
int cmp(const void *a, const void *b)
{
return *(int *)a - *(int *)b;
}
int main()
{
int cnt1[30], cnt2[30];
char s1[maxn], s2[maxn];
while (scanf("%s%s", s1, s2) != EOF) {
memset(cnt1, 0, sizeof(cnt1));
memset(cnt2, 0, sizeof(cnt2));
//printf("%s\n", s1);
//printf("%s\n", s2);
int len1 = strlen(s1);
for (int i = 0; i < len1; ++i) {
cnt1[s1[i] - 'A']++;
}
int len2 = strlen(s2);
for (int i = 0; i < len2; ++i) {
cnt2[s2[i] - 'A']++;
}
qsort(cnt1, 26, sizeof(int), cmp);
qsort(cnt2, 26, sizeof(int), cmp);
int flag = 1;
for (int i = 0; i < 26; ++i) {
//printf("%d: cnt1 = %d, cnt2 = %d\n", i, cnt1[i], cnt2[i]);
if (cnt1[i] != cnt2[i]) {
flag = 0;
break;
}
}
if (flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
上一篇: C#串口连接的读取和发送详解
下一篇: 低代码开发平台的敏捷之力
推荐阅读
-
UVA1339 - Ancient Cipher(思维)
-
UVA1339 Ancient Cipher(排序)
-
POJ2159 Ancient Cipher
-
Ancient Cipher UVALive - 3213
-
UVA1339 Ancient Cipher Java版
-
POJ 2159 Ancient Cipher G++
-
古老的密码(Ancient Cipher,NEERC 2004,UVa1339)
-
例题6-13 古代象形符号(Ancient Messages,World Finals 2011,UVa 1103)
-
1339 - Ancient Cipher 算法竞赛第四章
-
uva 1339 Ancient Cipher