fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4.  
  5. std::string encrypt_weaver(std::string const& input, std::string const& word) {
  6. std::string output;
  7. output.reserve(input.length());
  8.  
  9. for (std::size_t i = 0; i != input.length(); ++i) {
  10. output.push_back(((input[i] - 'a') + (word[i % word.length()] - 'a')) % ('z' - 'a' + 1) + 'a');
  11. }
  12.  
  13. return output;
  14. }
  15.  
  16.  
  17. int main() {
  18. std::string message;
  19. std::cout << "Введите строку." << std::endl;
  20. std::getline(std::cin, message);
  21.  
  22. std::string word;
  23. std::cout << "Введите слово." << std::endl;
  24. std::getline(std::cin, word);
  25.  
  26. std::cout << encrypt_weaver(message, word) << std::endl;
  27. }
Success #stdin #stdout 0s 3476KB
stdin
attackatdawn
lemon
stdout
Введите строку.
Введите слово.
lxfopvefrnhr