fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. std::string encrypt(std::string to_encrypt);
  5.  
  6. int main()
  7. {
  8. std::string sentence;
  9. std::cout << "Welcome. Enter a sentence: ";
  10. getline(std::cin, sentence);
  11. std::cout << sentence << '\n';
  12. std::string encrypted = encrypt(sentence);
  13. std::cout << encrypted << "\n\n";
  14. // system("pause");
  15. return 0;
  16. }
  17.  
  18. std::string encrypt(std::string to_encrypt)
  19. {
  20. for(char& c : to_encrypt)
  21. {
  22. if (c == ' ')
  23. continue;
  24. c += c <= (std::islower(c) ? 99 : 67) ? 23 : -3;
  25. }
  26. return to_encrypt;
  27. }
Success #stdin #stdout 0s 3416KB
stdin
random sentence
stdout
Welcome. Enter a sentence: random sentence
oxkalj pbkqbkzb