#include <iostream>
#include <string>
using namespace std;
class Password {
private:
string s;
public:
//构造函数
Password(const string s) {
this->s = s;
return;
}
//析构函数
~Password() {}
//判断第i个字符是否是大写英文字母
bool isCapital(const int i)const {
if (('A' <= this->s[i]) && (this->s[i] <= 'Z'))
return true;
return false;
}
//判断第i个字符是否是小写英文字母
bool isLowercase(const int i)const {
if (('a' <= this->s[i]) && (this->s[i] <= 'z'))
return true;
return false;
}
//判断第i个字符是否是数字
bool isNum(const int i)const {
if (('0' <= this->s[i]) && (this->s[i] <= '9'))
return true;
return false;
}
//判断第i个字符是英文字母、数字还是其他字符
const char judge(const int i)const {
//是大写字母
if (this->isCapital(i))
return 'C';
//是小写字母
if (this->isLowercase(i))
return 'L';
//是数字
if (this->isNum(i))
return 'N';
//是其他字符
return 'O';
}
//加密大写字母
void encryptCapital(const int i) {
if (this->isCapital(i))
if (this->s[i] == 'Z')
this->s[i] = 'a';
else
this->s[i] = this->s[i] - 'A' + 'a' + 1;
return;
}
//加密小写字母
void encryptLowercase(const int i) {
if (this->isLowercase(i))
if (this->s[i] == 'z')
this->s[i] = 'A';
else
this->s[i] = this->s[i] - 'a' + 'A' + 1;
return;
}
//加密数字
void encryptNum(const int i) {
if (this->isNum(i))
if (this->s[i] == '9')
this->s[i] = '0';
else
this->s[i] += 1;
}
//加密
void encrypt(void) {
//遍历字符串
for (int i = 0; i < this->s.size(); i++)
switch (this->judge(i)) {
case 'C':
this->encryptCapital(i);
break;
case 'L':
this->encryptLowercase(i);
break;
case 'N':
this->encryptNum(i);
break;
case 'O':
default:
break;
}
return;
}
//解密大写字母
void decryptCapital(const int i) {
if (this->isCapital(i))
if (this->s[i] == 'A')
this->s[i] = 'z';
else
this->s[i] = this->s[i] - 'A' + 'a' - 1;
return;
}
//解密小写字母
void decryptLowercase(const int i) {
if (this->isLowercase(i))
if (this->s[i] == 'a')
this->s[i] = 'Z';
else
this->s[i] = this->s[i] - 'a' + 'A' - 1;
return;
}
//解密数字
void decryptNum(const int i) {
if (this->isNum(i))
if (this->s[i] == '0')
this->s[i] = '9';
else
this->s[i] -= 1;
return;
}
//解密
void decrypt(void) {
//遍历字符串
for (int i = 0; i < this->s.size(); i++)
switch (this->judge(i)) {
case 'C':
this->decryptCapital(i);
break;
case 'L':
this->decryptLowercase(i);
break;
case 'N':
this->decryptNum(i);
break;
case 'O':
default:
break;
}
return;
}
//打印(<<运算符重载)
friend ostream& operator<<(ostream& cout, const Password p) {
cout << p.s;
return cout;
}
};
int main() {
string a, b;
while (cin >> a >> b) { // 注意 while 处理多个 case
Password pa(a), pb(b);
pa.encrypt();
cout << pa << endl;
pb.decrypt();
cout << pb << endl;
}
}
// 64 位输出请用 printf("%lld")