Advertisement
Guest User

Untitled

a guest
May 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. ```cpp
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string decod, encod;
  10. int n;
  11. int a[11][11];
  12. int b[11][11];
  13. int c[11][11];
  14.  
  15. cin >> n;
  16.  
  17. char * ch = new char[n*n];
  18. for (int j = 0; j < n*n; j++) {
  19. ch[j] = '#';
  20. }
  21.  
  22. for (int i = 0; i < n; i++) {//nuskaitymas
  23. for (int j = 0; j < n; j++) {
  24. cin >> a[i][j];
  25. c[i][j] = a[i][j];
  26. b[i][j] = a[i][j];
  27. }
  28. }
  29.  
  30. cin >> decod >> encod;
  31.  
  32. //atkodavimas new
  33.  
  34. for (int z = 0; z < decod.length(); z++) {
  35.  
  36. int x = 0;//atkodavimas ir isvedimas
  37. for (int i = 0; i < n; i++) {
  38. for (int j = 0; j < n; j++) {
  39. if (b[i][j] == 1 && decod[x] != '#') {
  40. cout << decod[x];
  41. decod[x] = '#';
  42. z++;
  43. }
  44. x++;
  45. }
  46. }
  47.  
  48. int y = 0;//pasukimas
  49. for (int i = 0; i <= n - 1; i++) {
  50. int x = 0;
  51. for (int j = n - 1; j >= 0; j--) {
  52. b[y][x] = c[j][i];
  53. x++;
  54. }
  55. y++;
  56. }
  57.  
  58. for (int i = 0; i < n; i++) {
  59. for (int j = 0; j < n; j++) c[i][j] = b[i][j];
  60. }
  61.  
  62. }
  63. cout << endl;
  64.  
  65.  
  66. for (int i = 0; i < n; i++) {
  67. for (int j = 0; j < n; j++) b[i][j] = a[i][j];
  68. }
  69.  
  70. for (int i = 0; i < n; i++) {
  71. for (int j = 0; j < n; j++) c[i][j] = a[i][j];
  72. }
  73. //atkodavimas
  74.  
  75. int x;
  76. x = 0;
  77.  
  78.  
  79. for (int z = 0; z < encod.length(); z++) {
  80. int y = 0;
  81. for (int i = 0; i < n; i++) {
  82. for (int j = 0; j < n; j++) {
  83. if (b[i][j] == 1 && x<encod.length()) {
  84. ch[y] = encod[x];
  85. encod[x] = '#';
  86. x++;
  87. z++;
  88. }
  89. y++;
  90.  
  91. }
  92. }
  93.  
  94. int ty = 0;//pasukimas
  95. for (int i = 0; i <= n - 1; i++) {
  96. int tx = 0;
  97. for (int j = n - 1; j >= 0; j--) {
  98. b[ty][tx] = c[j][i];
  99. tx++;
  100. }
  101. ty++;
  102. }
  103.  
  104. for (int i = 0; i < n; i++) {
  105. for (int j = 0; j < n; j++) c[i][j] = b[i][j];
  106. }
  107.  
  108. }
  109.  
  110. for (int i = 0; i < n*n; i++) {
  111. cout << ch[i];
  112. }
  113.  
  114. }
  115. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement