#include "library.h" const string alpha = "abcdefghijklmnopqrstuvwxyz "; const string other = "hzbdowumrjgaqitvenypcskxfl "; int find(const char c, const string s, const int pos) { if (pos >= s.length()) return -1; if (s[pos] == c) return pos; return find(c, s, pos + 1); } string encrypt(const string s, const string lookup, const string replacements) { if (s == "") return ""; const char c = s[0]; const int pos = find(c, lookup, 0); const char rep = replacements[pos]; const string empty = ""; return empty + rep + encrypt(s.substr(1)); } void main() { cout << "Enter a string: "; const string s = read_line(); const string t = encrypt(s, alpha, other); cout << "Encrypted = " << t << "\n"; const string u = encrypt(s, other, alpha); cout << "Decrypted = " << u << "\n"; }