POJ_2159

http://poj.org/problem?id=2159

解密用到了字母出现频率相同。

引用:https://blog.csdn.net/pp634077956/article/details/48319099

和https://blog.csdn.net/b2utyyomi/article/details/50838467

//POJ_2159
#include<stdio.h>
#include<string>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
int main(){
    int a[26],b[26];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    string Str;
    cin>>Str;
    int i,Len;
    Len = Str.length();
    for(i=0;i<Len;i++){
        a[Str[i]-'A']++;
    }
    cin>>Str;
    Len = Str.length();
    for(i=0;i<Len;i++){
        b[Str[i]-'A']++;
    }
    sort(a,a+26);
    sort(b,b+26);
    for(i=0;i<26;i++){
        if(a[i]!=b[i]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

 

posted @ 2019-10-28 17:15  智人心  阅读(88)  评论(0)    收藏  举报