#include const string alph = "abcdefghijklmnopqrstuvwxyz "; const string perm = "ktpembvwgcnqzaljhyfoxurdis "; int find(int pos, char c, string str) { if (pos >= str.length()) return -1; if (str[pos] == c) return pos; return find(pos + 1, c, str); } int find(char c, string str) /* returns position of c in str, counting from 0 or -1 if charcater doesn't appear */ { return find(0, c, str); } void encrypt(int pos, string s) { if (pos >= s.length()) cout << "\n"; else { int p = find(s[pos], perm); if (p == -1) cout << "?"; else cout << alph[p]; encrypt(pos + 1, s); } } void encrypt(string s) { encrypt(0, s); } void main() { while (true) { const string line = read_line(); encrypt(line); } } void test_one() { cout << perm << "\n"; while (true) { cout << "Enter character to find: "; const char c = read_char(); const int p = find(c, perm); if (p == -1) cout << "'" << c << "' Not found\n"; else cout << "'" << c << "' Position = " << p << "\n"; } }