算法竞赛入门经典第四章例题4-1 Ancient Cipher UVA - 1339

例题4-1
https://vjudge.net/problem/UVA-1339
只要个数对得上即可

#include
#include
#include
using namespace std;
int main() {
    string s, t;
    while (cin >> s >> t) {
        int A[2][26] = {};
        for (int i = 0;i0][s[i] - 'A'];
            ++A[1][t[i] - 'A'];
        }
        sort(A[0], A[0] + 26);
        sort(A[1], A[1] + 26);
        bool flag = true;
        for (int i = 0; i < 26; ++i)
            if (A[0][i] != A[1][i]) { flag = false; break; }
        if (flag) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

你可能感兴趣的:(算法竞赛入门经典第四章例题4-1 Ancient Cipher UVA - 1339)