#include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> char s[105], s2[105]; int t[26], t2[26]; void mycount(int t[], char s[], char alp[]){ //标记是s[]中各字母出现次数 for (int i = 0; i <strlen(s); i++){ for (int j = 0; j < 26; j++){ if (alp[j] == s[i]) { t[j]++; break; } } } } int cmp(const void*a, const void*b){ return *(int *)a - *(int *)b; } int main(){ char alp[26]; //creat an alphabet int d = 1; if (d){ alp[0] = 'A'; for (int i = 1; i < 26; i++){ alp[i] = alp[i - 1] + 1; } d = 0; } while (scanf("%s%s", s, s2) != EOF){ int len = strlen(s); mycount(t, s, alp); mycount(t2, s2, alp); qsort(t, 26, sizeof(int), cmp);//sort qsort(t2, 26, sizeof(int), cmp); int d2 = 1; for (int i = 0; i < 26; i++){ if (t[i] != t2[i]){ d2 = 0; break; } } if (d2) printf("YES\n"); else printf("NO\n"); memset(t, '\0', 26 * sizeof(int)); memset(t2, '\0', 26 * sizeof(int)); memset(s, '\0', 105 * sizeof(char)); memset(s2, '\0',105 * sizeof(char)); } return 0; }