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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!