Advertisement
ShadyLiar

Untitled

May 4th, 2023
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. std::map<char, std::string> MorzeDict = {
  8.             {'A', ".-"}, {'B', "-..."}, {'C', "-.-."}, {'D', "-.."},
  9.             {'E', "."}, {'F', "..-."}, {'G', "--."}, {'H', "...."},
  10.             {'I', ".."}, {'J', ".---"}, {'K', "-.-"}, {'L', ".-.."},
  11.             {'M', "--"}, {'N', "-."}, {'O', "---"}, {'P', ".--."},
  12.             {'Q', "--.-"}, {'R', ".-."}, {'S', "..."}, {'T', "-"},
  13.             {'U', "..-"}, {'V', "...-"}, {'W', ".--"}, {'X', "-..-"},
  14.             {'Y', "-.--"}, {'Z', "--.."}, {' ', " "}
  15.     };
  16.  
  17. class Morze {
  18.  
  19. private:
  20.     std::string m_Word = "";
  21.  
  22.  
  23.  
  24.  
  25. public:
  26.     Morze(std::string Word) : m_Word(Word) {};
  27.  
  28.     std::string Encode() {
  29.  
  30.     std::string encode = "";
  31.     for (char c : m_Word)
  32.     {
  33.         encode += MorzeDict.find(toupper(c))->second;
  34.     }
  35.  
  36.     std::cout << encode << std::endl;
  37.     return encode;
  38. }
  39. };
  40.  
  41.  
  42.  
  43.  
  44.  
  45. int main()
  46. {
  47.    
  48.     Morze abc("awfafawf");
  49.    
  50.     abc.Encode();
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement