30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
1 #include <iostream>
|
|
2 #include <string>
|
|
3 #include <algorithm>
|
|
4
|
|
5 int main() {
|
|
6 const std::string original_alphabet = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
|
|
7 const std::string shuffled_alphabet = "K>d~G`V]W@qJ{j\"|l'U[=(&^zF/\\aE%xI$T,!H#;p+*gC?)s.f}Z:b>PY<B_Ot-eNMLkSRuQc r(w)yXvnm";
|
|
8
|
|
9 std::cout << "Enter string to encode: ";
|
|
10 std::string input_string;
|
|
11 std::getline(std::cin, input_string);
|
|
12
|
|
13 std::string encoded_string;
|
|
14 encoded_string.reserve(input_string.length());
|
|
15
|
|
16 for (char original_char : input_string) {
|
|
17 size_t pos = original_alphabet.find(original_char);
|
|
18 if (pos != std::string::npos) {
|
|
19 encoded_string += shuffled_alphabet[pos];
|
|
20 } else {
|
|
21 encoded_string += original_char;
|
|
22 }
|
|
23 }
|
|
24
|
|
25 std::cout << "Encoded string: " << encoded_string << std::endl;
|
|
26
|
|
27 return 0;
|
|
28 }
|
|
|