Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
58
Task/Morse-code/D/morse-code.d
Normal file
58
Task/Morse-code/D/morse-code.d
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import std.conv;
|
||||
import std.stdio;
|
||||
|
||||
immutable string[char] morsecode;
|
||||
|
||||
static this() {
|
||||
morsecode = [
|
||||
'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': "----."
|
||||
];
|
||||
}
|
||||
|
||||
void main(string[] args) {
|
||||
foreach (arg; args[1..$]) {
|
||||
writeln(arg);
|
||||
foreach (ch; arg) {
|
||||
if (ch in morsecode) {
|
||||
write(morsecode[ch]);
|
||||
}
|
||||
write(' ');
|
||||
}
|
||||
writeln();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue