POJ-2159-Ancient Cipher

水题,

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char stra[101],strb[101];
int counta[27],countb[27];
int main()
{
    while(scanf("%s%s",stra,strb)!=EOF)
    {
	memset(counta,0,sizeof(counta));
	memset(countb,0,sizeof(countb));
	for(int i=0;i<strlen(stra);i++)
	    counta[stra[i]-'A']++;
	for(int i=0;i<strlen(strb);i++)
	    countb[strb[i]-'A']++;
	sort(counta,counta+26);
	sort(countb,countb+26);
	int flag=0;
	for(int i=0;i<26;i++)
	    if(counta[i]!=countb[i])
	    {
		flag=1;
		break;
	    }
	if(flag)
	    printf("NO\n");
	else
	    printf("YES\n");
    }
    return 0;
}


你可能感兴趣的:(POJ-2159-Ancient Cipher)