#include <cctype> #include <iostream> using namespace std; char srcstr[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; char encstr[] = "BCDEFGHIJKLMNOPQRSTUVWXYZAbcdefghijklmnopqrstuvwxyza1234567890"; char decstr[] = "ZABCDEFGHIJKLMNOPQRSTUVWXYzabcdefghijklmnopqrstuvwxy9012345678"; void encrypt2(string& str) { int len = str.length(); for (int i = 0; i < len; i++) { if (isupper(str[i])) { str[i] = encstr[str[i] - 'A' + 26]; } else if (islower(str[i])) { str[i] = encstr[str[i] - 'a']; } else { str[i] = encstr[str[i] - '0' + 52]; } } return; } void decrypt2(string& str) { int len = str.length(); for (int i = 0; i < len; i++) { if (isupper(str[i])) { str[i] = decstr[str[i] - 'A' + 26]; } else if (islower(str[i])) { str[i] = decstr[str[i] - 'a']; } else { str[i] = decstr[str[i] - '0' + 52]; } } return; } int main() { string encryptStr; // 要加密的字符串 string decryptStr; // 要解密的字符串 cin >> encryptStr; cin >> decryptStr; // 加密函数 encrypt2(encryptStr); // 解密函数 decrypt2(decryptStr); cout << encryptStr << endl; cout << decryptStr << endl; return 0; } // 64 位输出请用 printf("%lld")