Advertisement
O_Egor

POLIBEY`s SHIFR

Mar 23rd, 2021
890
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <map>
  5. using namespace std;
  6. map<int,pair<int,int> >m;
  7.  
  8. void create_table()
  9. {
  10.     int k=0;
  11.     for(int i=0; i<6; i++)
  12.     {
  13.         for(int j=0; j<6; j++)
  14.         {
  15.             m['À'+k++-64]= {i,j};
  16.             if(k==33)
  17.             {
  18.                 m[' ']= {i,5};
  19.                 m['-']= {i,4};
  20.                 m[',']= {i,3};
  21.                 m['.']= {i,2};
  22.                 break;
  23.             }
  24.         }
  25.     }
  26. }
  27.  
  28. void code(string s)
  29. {
  30.     for(int i=0; i<s.size(); i++)
  31.     {
  32.         auto t=m[s[i]];
  33.         cout<<(char)(t.first+'À'-64)<<(char)(t.second+'À'-64);
  34.     }
  35. }
  36. void decode(string s){
  37. for(int i=0;i<s.size();i+=2){
  38.     pair<int,int> p={s[i]-'À'+64,s[i+1]-'À'+64};
  39.     //cout<<p.first<<' '<<p.second<<endl;
  40.     for(auto j:m){
  41.     pair<int,int> p1=j.second;
  42.     //cout<<p1.first<<' '<<p1.second<<endl;
  43.         if(p1.first==p.first && p1.second==p.second){
  44.             cout<<(char)(j.first+'A'-65);
  45.             break;
  46.         }
  47.     }
  48.  
  49. }
  50.  
  51. }
  52.  
  53.  
  54. int main()
  55. {
  56.     string s;
  57.     getline(cin,s);
  58.     create_table();
  59.     code(s);
  60.     //decode(s);
  61.  
  62.  
  63.  
  64.  
  65.     return 0;
  66. }
  67. //ДАБВГВВДЕЕВГВВБЕБВАББВЕБ
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement