Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- std::map<char, std::string> MorzeDict = {
- {'A', ".-"}, {'B', "-..."}, {'C', "-.-."}, {'D', "-.."},
- {'E', "."}, {'F', "..-."}, {'G', "--."}, {'H', "...."},
- {'I', ".."}, {'J', ".---"}, {'K', "-.-"}, {'L', ".-.."},
- {'M', "--"}, {'N', "-."}, {'O', "---"}, {'P', ".--."},
- {'Q', "--.-"}, {'R', ".-."}, {'S', "..."}, {'T', "-"},
- {'U', "..-"}, {'V', "...-"}, {'W', ".--"}, {'X', "-..-"},
- {'Y', "-.--"}, {'Z', "--.."}, {' ', " "}
- };
- class Morze {
- private:
- std::string m_Word = "";
- public:
- Morze(std::string Word) : m_Word(Word) {};
- std::string Encode() {
- std::string encode = "";
- for (char c : m_Word)
- {
- encode += MorzeDict.find(toupper(c))->second;
- }
- std::cout << encode << std::endl;
- return encode;
- }
- };
- int main()
- {
- Morze abc("awfafawf");
- abc.Encode();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement