Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```cpp
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- string decod, encod;
- int n;
- int a[11][11];
- int b[11][11];
- int c[11][11];
- cin >> n;
- char * ch = new char[n*n];
- for (int j = 0; j < n*n; j++) {
- ch[j] = '#';
- }
- for (int i = 0; i < n; i++) {//nuskaitymas
- for (int j = 0; j < n; j++) {
- cin >> a[i][j];
- c[i][j] = a[i][j];
- b[i][j] = a[i][j];
- }
- }
- cin >> decod >> encod;
- //atkodavimas new
- for (int z = 0; z < decod.length(); z++) {
- int x = 0;//atkodavimas ir isvedimas
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (b[i][j] == 1 && decod[x] != '#') {
- cout << decod[x];
- decod[x] = '#';
- z++;
- }
- x++;
- }
- }
- int y = 0;//pasukimas
- for (int i = 0; i <= n - 1; i++) {
- int x = 0;
- for (int j = n - 1; j >= 0; j--) {
- b[y][x] = c[j][i];
- x++;
- }
- y++;
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) c[i][j] = b[i][j];
- }
- }
- cout << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) b[i][j] = a[i][j];
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) c[i][j] = a[i][j];
- }
- //atkodavimas
- int x;
- x = 0;
- for (int z = 0; z < encod.length(); z++) {
- int y = 0;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (b[i][j] == 1 && x<encod.length()) {
- ch[y] = encod[x];
- encod[x] = '#';
- x++;
- z++;
- }
- y++;
- }
- }
- int ty = 0;//pasukimas
- for (int i = 0; i <= n - 1; i++) {
- int tx = 0;
- for (int j = n - 1; j >= 0; j--) {
- b[ty][tx] = c[j][i];
- tx++;
- }
- ty++;
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) c[i][j] = b[i][j];
- }
- }
- for (int i = 0; i < n*n; i++) {
- cout << ch[i];
- }
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement