Question
Morse Code Programming challenge description: You have received a text encoded with Morse code and want to decode it. Input: Your program should read lines
Morse Code Programming challenge description: You have received a text encoded with Morse code and want to decode it. Input: Your program should read lines from standard input. Each line contains a Morse code message. Each letter in the code is separated by a space char, each word is separated by 2 space chars. The input will contain encoded letters and numbers only. Output: Print out the decoded words. Test 1 Test Input Download Test 1 Input .- ...- ..--- .-- .... .. . -.-. -..- ....- ..... Expected Output Download Test 1 Input AV2WHIECX 45 Test 2 Test Input Download Test 2 Input -... .... ...-- Expected Output Download Test 2 Input BH3
#include
#include
using namespace std;
int main() {
string line;
while (getline(cin, line)) {
if(line == ' ') { cout << ""; }
else if(line == ' ' ) { cout << " "; }
else { cout << line << endl; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started