#include
#define MORSE_NONE NULL
const char* morse_ascii[] = {
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
"", MORSE_NONE, "", "", /* , _ . / */
"-----", "", "", "", /* 0 1 2 3 */
"", "", "", "", /* 4 5 6 7 */
"", "", MORSE_NONE, MORSE_NONE, /* 8 9 _ _ */
MORSE_NONE, "", MORSE_NONE, "", /* _ = _ ? */
MORSE_NONE, "*-", "", "", /* _ A B C */
"", "", "", "", /* D E F G */
"", "", "", "", /* H I J K */
"", "", "", "", /* L M N O */
"", "", "", "", /* P Q R S */
"", "", "", "", /* T U V W */
"", "", "", MORSE_NONE, /* X Y Z _ */
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
MORSE_NONE, "", "", "", /* _ a b c */
"", "", "", "", /* d e f g */
"", "", "", "", /* h i j k */
"", "", "", "", /* l m n o */
"", "", "", "", /* p q r s */
"", "", "", "", /* t u v w */
"", "", "", MORSE_NONE, /* x y z _ */
MORSE_NONE, MORSE_NONE, MORSE_NONE, MORSE_NONE,
};
int main() {
char in;
while((in = getchar()) > 31) {
printf("%s ", morse_ascii[in]);
}
return 0;
}
Wpisz zgodnie z komentarzem swoje translacje, bo tego już za ciebie nie zrobię. Wpisałem ci przykładowo ‘0’ i ‘A’, dla sprawdzenia sobie jak to działa._
w komentarzu znaczy, że odpowiednia pozycję należy pominąć <=> nie dotykaj MORSE_NONE, to po prostu zaznaczenie, że tam nie ma kodu w morsie, który jest odpowiednikiem w ascii. Być może coś pominąłem, ale tak jak mówie - przejrzyj tablicę ASCII + uzupełnij.