Tuesday, December 17, 2019

Morse Code:

Morse code is a method of transmitting text information as a series of on-off tones, lights, or clicks that can be directly understood by a skilled listener or observer without special equipment. It is named for Samuel F. B. Morse, an inventor of the telegraph.

The algorithm is very simple. Every character in the English language is substituted by a series of ‘dots’ and ‘dashes’ or sometimes just singular ‘dot’ or ‘dash’ and vice versa.

Every text string is converted into the series of dots and dashes. For this every character is converted into its Morse code and appended in encoded message. Here we have copied space as it is. And we have not considered numbers, only alphabets.

 

Input :    p    r  o  g   r    a   m 

Output : .--. .-. --- --. .-.  .-   --

 

Input :     p    p    s

Output : .--.  .--.  ...

 


No comments:

Post a Comment