Advertisement
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 alpha = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя";
- int code(char s)
- {
- for (int i = 0; i < alpha.length(); i++) {
- if (s == alpha[i])
- return i;
- }
- }
- int main() {
- system("chcp 1251");
- system("cls");
- setlocale(LC_ALL, "Russian");
- ifstream ifst;
- ofstream ofst;
- string alphaB[33][33] = { "" };
- for (int i = 0; i < 33; ++i)
- {
- int j = 0;
- int shift = i;
- cout << shift << endl;
- while (j < 33)
- {
- if (shift == 33) shift -= 33;
- alphaB[i][j] = alpha[shift];
- shift++;
- j++;
- }
- }
- for (int i = 0; i < 33; ++i)
- {
- for (int j = 0; j < 33; ++j)
- cout << alphaB[i][j] << ' ';
- cout << endl;
- }
- string message = "стартовый";
- //string message = "НЮрйПлуаё";
- ofstream output("out.txt");
- cout << endl;
- int o=0;
- string key = "абвгд";
- 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 -= 33;
- //if (resultcode >= 66) resultcode -= 33;
- int stroka = abs(code(message[i])) ;
- int stolb = abs(key[k]) ;
- cout << message[i] << ' ' << stroka << ' '<< stolb<<' '<<endl;
- 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 += 33;
- if (resultcode >= 66) resultcode -= 33;
- cout << message[i] << ' ' << alpha[resultcode] << ' ' << endl;
- resultcode = 0;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement