Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <locale>
- #include <Windows.h>
- using namespace std;
- int rows;
- int cols;
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- setlocale(LC_ALL, "Russian");
- bool prov = true;
- string str;
- cout << "Enter your frase: ";
- getline(cin, str);
- for (int i = 0; i < str.size(); i++) {
- str.at(i) = toupper(str.at(i));
- }
- while (prov) {
- str.find(' ');
- str.erase(str.find(' '), 1);
- if (str.find(' ') == string::npos) {
- prov = false;
- }
- }
- cout << str<<endl;
- ///////////////////////////////////////////////////////////////////////////////
- cout << "Введите кол-во строк: ";
- cin >> rows;
- cout << "Введите кол-во столбцов: ";
- cin >> cols;
- char **mas = new char*[rows];
- for (int i = 0; i < rows; ++i) {
- mas[i] = new char[cols];
- }
- ////////////////////////////////////////////////////////////////////////////////
- int k = 0;
- for (int i = 0; i<rows; ++i)
- for (int j = 0; j < cols; j++)
- if (k < str.length()+1 ) {
- mas[i][j] = str[k];
- k++;
- }
- for (int i = 0; i<rows; i++) {
- for (int j = 0; j < cols; j++) {
- cout << mas[i][j]<<" ";
- }
- cout << endl;
- }
- /////////////////////////////////////////////////////////////////////////////////
- cout << "\n\n\n\n";
- cout << "Демонстрация простого шифра перестановки: \n";
- for (int j = 0; j<cols; j++) {
- for (int i = 0; i<rows; i++)
- cout << mas[i][j];
- cout << " ";
- }
- ////////////////////////////////////////////////////////////////////////////////////
- cout << "\n\n\n\n";
- cout << "Демонстрация дешифровки простого шифра перестановки : \n";
- for (int i = 0; i<rows; i++) {
- for (int j = 0; j<cols; j++)
- cout << mas[i][j];
- }
- cout << "\n";
- ////////////////////////////////////////////////////////////////////////////////////////
- for (int i = 0; i < rows; i++) {
- delete[] mas[i];
- }
- delete[] mas;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement