Skip to content
View Khalaf2003's full-sized avatar
Block or Report

Block or report Khalaf2003

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
Khalaf2003/README.md

#include #include #include

using namespace std;

map<char, string> charToMorse = { {'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', "--.."}, {'1', ".----"}, {'2', "..---"}, {'3', "...--"}, {'4', "....-"}, {'5', "....."}, {'6', "-...."}, {'7', "--..."}, {'8', "---.."}, {'9', "----."}, {'0', "-----"} };

string textToMorse(const string& text) { stringstream result; for (char c : text) { if (c == ' ') { result << " "; // 3 spaces for word separation } else { result << charToMorse[toupper(c)] << " "; // Use map to get Morse code for each character } } return result.str(); }

string morseToText(const string& morse) { stringstream result; stringstream ss(morse); string code; while (ss >> code) { for (const auto& entry : charToMorse) { if (entry.second == code) { result << entry.first; break; } } } return result.str(); }

int main() { string plainText = "I love C plus plus"; string morseText = textToMorse(plainText); cout << "Plain text: " << plainText << endl; cout << "Morse text: " << morseText << endl;

string originalText = morseToText(morseText);
cout << "Original text: " << originalText << endl;

return 0;

}

Popular repositories Loading

  1. Khalaf2003 Khalaf2003 Public

    Config files for my GitHub profile.