#include int mindex(char search[], char target); // decoder: // allow the user to enter a string of text and output the decoded version // of the text. // the encoding involves translating characters as follows: // A -> P // B -> Q // etc. // Here's the complete list: // lmnopzyxwvustrqabcfedghijk // abcdefghijklmnopqrstuvwxyz int main() { char outstr[] = "abcdefghijklmnopqrstuvwxyz"; char instr[] = "lmnopzyxwvustrqabcfedghijk"; char cur; int m; do { cin.get(cur); m = mindex(instr, cur); if (m == -1) cout << cur; else cout << outstr[m]; } while ( cur != '\n'); cout << endl; } // mindex: searches through a character array for a particular character // and returns the index into the array of the found character // argument 1: character array // argument 2: character to search for // int mindex(char search[], char target) { int i; for (i=0; search[i] != '\0'; ++i) if (search[i] == target) return i; return -1; }