首页 > 其他 > 详细

UVa1339 Ancient Cipher

时间:2015-06-27 15:53:52      阅读:216      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!