C++
坑真多

思路:对于字符串映射由原先的
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
改为
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

T R A I L B Z E S C D F G H J K M N O P Q U V W X Y
即把给定的密钥去重后,把密钥中的字符从序列[A-Z]中挪到最前面。
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main()
{
    string str1, str2;
    while(cin >> str1)
    {
        getchar();
        getline(cin, str2);
        string oldEncryp, newEncryp;
        for(unsigned c = 'A'; c <= 'Z'; ++c)
        {
            oldEncryp += c;
        }
        for(auto &c: str1)
        {
            c = toupper(c);
            if(newEncryp.find(c) == string::npos)
            {
                newEncryp += c;
                oldEncryp.erase(oldEncryp.find(c), 1);
            }
        }
        newEncryp += oldEncryp;

        for(auto &c : str2)
        {
            if(c >= 'a' && c <= 'z')
            {
                c = newEncryp[c - 'a'] - 'A' + 'a';
            }
            else if(c >= 'A' && c <= 'Z')
            {
                c = newEncryp[c - 'A'];
            }
        }
        cout << str2 << endl;
    }
    return 0;
}