Caesar 密码解密 - GESP 三级
#include
string decrypt(string cipher) { string plaintext = ""; for (int i = 0; i < cipher.length(); i++) { if (isalpha(cipher[i])) { char decryptedChar = cipher[i] - 5; if (decryptedChar < 'A') { decryptedChar += 26; } plaintext += decryptedChar; } else { plaintext += cipher[i]; } } return plaintext; }
int main() { string cipher; getline(cin, cipher); string plaintext = decrypt(cipher); cout << plaintext << endl; return 0; }
原文地址: https://www.cveoy.top/t/topic/pgMh 著作权归作者所有。请勿转载和采集!