fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. const std::string data =
  9. "A gentle, dull flickering flame, burns in the marble hearth. "
  10. "Its dim light scarcely illuminates the small, cozy room with its "
  11. "figure of a wooden desk at which Allen was roaming through his "
  12. "memories. Thinking back in the past where he once had a "
  13. "friendship which was out righteously incredible. She was the "
  14. "girl of his dreams, in a way which she had everything he had "
  15. "ever sought out in a beautiful and clever girl. Most of all she "
  16. "had his heart. Her style was incredible in the way the outfits "
  17. "she would wear would match perfectly giving a deep vibrant lively feeling.";
  18.  
  19. char choice;
  20. const char decrypt = 'd';
  21. const char encrypt = 'e';
  22.  
  23.  
  24. while (std::cin >> choice && (choice == decrypt || choice == encrypt))
  25. {
  26. if (choice == decrypt)
  27. {
  28. // consume any leading whitespace:
  29. std::cin >> std::ws;
  30.  
  31. // read in the line of text that contains the code to decrypt.
  32. std::string line;
  33. std::getline(std::cin, line);
  34.  
  35. // convert the line into a stream:
  36. std::istringstream code_stream(line);
  37.  
  38. int code;
  39. // while stream extraction is successful,
  40. while (code_stream >> code)
  41. std::cout << data[code]; // output the decrypted character.
  42.  
  43. }
  44. else
  45. std::cout << "Unimplemented";
  46.  
  47. std::cout << std::endl;
  48. }
  49. }
Success #stdin #stdout 0s 3480KB
stdin
d 28 33 18 10 3 15 2
stdout
abcdefg