Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <string>
- #include <vector>
- using namespace std;
- string getType(char s, string alphabet) {
- if (s >= alphabet[0] && s <= alphabet[1]) {
- return "low";
- } else if (s >= alphabet[2] && s <= alphabet[3]) {
- return "up";
- }
- return "none";
- }
- void decode(string message, int index) {
- vector<string> langs {"аяАЯ32", "azAZ26"};
- string alphabet = langs[index].substr(0, 4);
- int countLetters = stoi(langs[index].substr(4));
- cout << "\nK0 " << message << "\n";
- for (int i = 0; i < countLetters - 1; i++) {
- for (int j = 0; j < message.size(); j++) {
- string type = getType(message[j], alphabet);
- if (type == "none") continue;
- message[j] = char(char(message[j]) + 1);
- if (getType(message[j], alphabet) != type) {
- message[j] = char(char(message[j]) - countLetters);
- }
- }
- cout << "K" << i + 1 << " " << message << "\n";
- }
- return;
- }
- int main() {
- // SetConsoleCP(1251);
- // SetConsoleOutputCP(1251);
- vector<string> langs {"ru", "eng"};
- string message, lang;
- // int numOfLang = -1;
- int numOfLang = 1;
- // cout << "Введите язык шифра ('ru'(w/o 'ё'), 'eng'): ";
- // getline(cin, lang);
- //
- //
- // for (int i = 0; i < langs.size(); i++) {
- // if (langs[i] == lang) {
- // numOfLang = i;
- // break;
- // }
- // }
- // if (!(numOfLang + 1)) {
- // cout << "Язык не поддерживается!";
- // return 0;
- // }
- // cout << "Введите текст:\n";
- cout << "Enter text: ";
- getline(cin, message);
- decode(message, numOfLang);
- cout << "DONE.";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement