-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (48 loc) · 2 KB
/
Copy pathProgram.cs
File metadata and controls
53 lines (48 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
namespace morzeCode
{
class Program
{
public static string[] tableMorze = new string[] {".-", "-...", "-.-.", "-..",
".", "..-.", "--.", "....",
"..", ".---", "-.-", ".-..",
"--", "-.", "---", ".--.",
"--.-", ".-.", "...", "-",
"..-", "...-", ".--",
"-..-", "-.--", "--.."
};
public static string[] abc = 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"
};
public static string endMessage = "Your message: ";
static string morzeDecoder(string morzeMessage)
{
string[] message = morzeMessage.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < message.Length; i++)
{
for (int j = 0; j <= 25; j++)
{
if (message[i] == tableMorze[j])
{
endMessage += abc[j];
}
}
}
return endMessage;
}
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Good afternoon! Let's decode your message");
Console.WriteLine("Enter the morse code\n");
string morzeMessage = Console.ReadLine();
Console.WriteLine(morzeDecoder(morzeMessage));
endMessage = "Message: ";
Console.WriteLine(" ");
}
}
}
}