Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <string>
  5. using namespace std;
  6. int main()
  7. {
  8.  
  9. setlocale(LC_ALL, "russian");
  10.  
  11. const int m = 5;
  12. const int n = 5;
  13. int i, j, size, l,i1,j1;
  14. int check;
  15. string message;
  16. cout << "Enter your message" << endl;
  17. getline(cin, message);
  18. size = message.size();
  19. cout << "text lenght = " << size << endl;
  20.  
  21.  
  22. char A[m][n] = { { 'A', 'B', 'C', 'D', 'E'},
  23. { 'F', 'G', 'H', 'I', 'K'},
  24. { 'L', 'M', 'N', 'O', 'P'},
  25. { 'Q', 'R', 'S', 'T', 'U'},
  26. { 'V', 'W', 'X', 'Y', 'Z'} };
  27.  
  28. cout << "1 - crypt / 2 - decrypt" << endl;
  29. cin >> check;
  30.  
  31. if (check == 1)
  32. {
  33.  
  34. for (l = 0; l < size; l++)
  35. {
  36. for (int i = 0; i < m; i++)
  37. {
  38. for (int j = 0; j < n; j++)
  39. {
  40. if (message[l] == A[i][j])
  41. {
  42. cout << i + 1 << j + 1 << ' ';
  43. }
  44. }
  45. }
  46.  
  47.  
  48. }
  49.  
  50. cout << endl;
  51. }
  52. else
  53. {
  54.  
  55. for (i = 0; i < size; i=i+2)
  56. {
  57. for ( j = 1; j < size; j=j+2)
  58. {
  59. i1 = message[i];
  60. j1=message[j] ;
  61.  
  62. cout << A[i1][j1];
  63.  
  64. }
  65.  
  66. }
  67. cout << endl;
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement