Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Collections.Generic;
- namespace MorseCodeTranslator
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- var morseCodeDictionary = new Dictionary<string, 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"}
- };
- string [] morseCodeArray = Console.ReadLine().Split();
- StringBuilder sb = new StringBuilder();
- foreach (var code in morseCodeArray)
- {
- if (code == "|")
- {
- sb.Append(" ");
- }
- else if (morseCodeDictionary.ContainsKey(code))
- {
- sb.Append(morseCodeDictionary[code]);
- }
- }
- Console.WriteLine(sb);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement