UVa1339 - Ancient Cipher

//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\n"); else printf("NO\n");
    }
	return 0;
}

posted @ 2017-04-03 09:32  gwj1139177410  阅读(71)  评论(0编辑  收藏  举报
选择