Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <fstream>
- #include <string>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- //Объявляем массив символов русского и английского алфавита
- string symbols = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
- int code(char s)
- {
- for (int i = 1; i <= symbols.length(); i++)
- if (s == symbols[i])
- return i;
- }
- int main() {
- system("chcp 1251");
- system("cls");
- setlocale(LC_ALL, "Russian");
- ifstream ifst;
- ofstream ofst;
- string alpha = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
- string key = "лежбище";
- string message = "ЧлтыВхуйу";
- //string message = "НЮрйПлуаё";
- ofstream output("out.txt");
- int o=1;
- if (o == 0)
- {
- int k = 0;
- int cod;
- int resultcode=0;
- string out;
- for (int i = 0; i < message.length(); i += 1)
- {
- if (k >= key.length())
- k = 0;
- k++;
- resultcode += code(message[i]);
- resultcode += code(key[k]);
- if (resultcode >= 66) resultcode -= 66;
- if (resultcode >= 66) resultcode -= 66;
- cout << message[i] << ' ' << alpha[resultcode]<< ' '<<endl;
- output << alpha[resultcode];
- resultcode = 0;
- }
- }
- if (o == 1)
- {
- int k = 0;
- int cod;
- int resultcode = 0;
- string out;
- for (int i = 0; i < message.length(); i += 1)
- {
- if (k >= key.length())
- k = 0;
- k++;
- resultcode += code(message[i]);
- resultcode -= code(key[k]);
- if (resultcode <1) resultcode += 66;
- if (resultcode >= 66) resultcode -= 66;
- cout << message[i] << ' ' << alpha[resultcode] << ' ' << endl;
- resultcode = 0;
- }
- }
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment