Medzinárodná Morseova abeceda
Medzinárodná Morseova abeceda [vyslov: morzeova] (iné názvy: Morseova abeceda, Morsova abeceda[1], Morseova telegrafická abeceda, Morseho abeceda [vyslov: morzeho], hovorovo morzeovka) je sústava telegrafných signálov zodpovedajúcich písmenám, čísliciam a iným znakom, ktoré sa používajú pri písaní. V grafickom vyjadrení je to sústava bodiek a čiarok, časovo bodka predstavuje krátky signál a čiarka dlhý signál. Autorom abecedy je Samuel Finley Breese Morse.
|
|
|
|
---|
T | M | O | Ch | 0 / 9 |
Ö | 8 | |||
G | Q | Ñ | ||
Z | 7 | |||
N | K | Y | ||
C | ||||
D | X | |||
B | 6 | |||
E | A | W | J | 1 / ' |
P | ||||
R | Ä | |||
L | ||||
I | U | Ü | 2 | |
F | ||||
S | V | 3 | ||
H | 4 / 5 |
Program v C#
[upraviť | upraviť zdroj]using System;
namespace x30x12x2021
{
internal class Program
{
static void Main()
{
while (true)
{
Console.WriteLine("Zadejte text určený pre prevod:");
string line = Console.ReadLine();
if (string.IsNullOrEmpty(line)) break;
else
{
Console.WriteLine();
if (line[0] == '.' || line[0] == '-') //bola zadána Morseova ábeceda?
{
string[] vs = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); //medzery v Morseovke
for (int i = 0; i < vs.Length; i++)
{
Console.Write(Morse.DecodeMorseCode(vs[i]));
}
}
else //nebola zadána Morseovka, pracujem s textom
{
for (int i = 0; i < line.Length; i++)
{
Console.Write(Morse.EncodeToMorseCode(line[i]));
Console.Write(" "); //oddelovač
}
}
Console.WriteLine();
}
}
}
}
static class Morse
{
#region ONLY READ
private static readonly string[,] MorseCodes = new string[,]
{
{"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" , "--.."},
{"0" , "-----"},
{"1" , ".----"},
{"2" , "..---"},
{"3" , "...--"},
{"4" , "....-"},
{"5" , "....."},
{"6" , "-...."},
{"7" , "--..."},
{"8" , "---.."},
{"9" , "----."}
};
#endregion
public static string EncodeToMorseCode(char c)
{
var uc = char.ToUpper(c);
int len = MorseCodes.GetLength(0);
for (int i = 0; i < len; i++)
{
if (uc == MorseCodes[i, 0][0]) return MorseCodes[i, 1];
}
return uc.ToString();
}
public static string DecodeMorseCode(string m)
{
int len = MorseCodes.GetLength(0);
for (int i = 0; i < len; i++)
{
if (m == MorseCodes[i, 1]) return MorseCodes[i, 0];
}
return "?";
}
}
}
Pozri aj
[upraviť | upraviť zdroj]Poznámka
[upraviť | upraviť zdroj]Text is available under the CC BY-SA 4.0 license; additional terms may apply.
Images, videos and audio are available under their respective licenses.