码迷,mamicode.com
首页 > 其他好文 > 详细

UVa1339 Ancient Cipher

时间:2015-06-27 15:57:06      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

#include <iostream>
#include <string>
#include <cstring> // for memset
#include <algorithm>
using namespace std;

int main()
{
    int ce[26], co[26];
    string encrypted, orginal;
    string::size_type i, len;
    ios::sync_with_stdio(false);
    while (cin >> encrypted >> orginal)
    {
        memset(ce, 0, sizeof(ce));
        memset(co, 0, sizeof(co));
        len = orginal.length();
        for (i = 0; i < len; ++i)
        {
            ++ce[encrypted[i]-‘A‘];
            ++co[orginal[i]-‘A‘];
        }
        
        sort(ce, ce+26);
        sort(co, co+26);
        if (equal(ce, ce+26, co))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

UVa1339 Ancient Cipher

标签:

原文地址:http://www.cnblogs.com/danny1221/p/4603991.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!