UVa1339

//UVa1339 - Ancient Cipher
//已AC
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int cmp(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}
int main(){
	//freopen("date4.in","r",stdin);
	char a[200], b[200];
	while(scanf("%s%s", a,b) != EOF){
		int len = strlen(a);
		int cnt1[26] = {0}, cnt2[26] = {0};
		//统计
		for(int i=0; i < len; i++){
			cnt1[a[i] - 'A']++;
			cnt2[b[i] - 'A']++;
		}
		//排序
		qsort(cnt1,26,sizeof(int),cmp);
		qsort(cnt2,26,sizeof(int),cmp);
		//输出
		int ok = 1;
		for(int i = 0; i < 26; i++)
			if(cnt1[i] != cnt2[i]) ok = 0;
		if(ok) printf("YES
"); else printf("NO
");
    }
	return 0;
}

原文地址:https://www.cnblogs.com/gwj1314/p/9444927.html