#include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
setlocale (LC_ALL, "Russian");
char text[1000]="";
char text2[1000]="";
char text3[1000]="";
int x, H, W;
cout << "Текст: "; cin >> text;
cin >> x; cin >> H; cin >> W;
char result_1[1000]="";
for (int i=0; i<x*H*W; i++)
result_1[((i/x)%W*H+(i/x)/W)*x+(i%x)]=(i<strlen(text)) ? text[i] : '_';
cout << "Шифр #2: " << result_1 << "\n";
cin >> text3;
char result_2[1000]="";
for (int i=0; i<x*H*W; i++)
result_2[((i/x)%H*W+(i/x)/H)*x+(i%x)]=(text3[i]=='_') ? ' ' : text3[i];
cout << "Расшифровка #2: " << result_2 << "\n";
}