|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <ctype.h> ! 3: ! 4: char *dit = "dit"; ! 5: char *daw = "daw"; ! 6: ! 7: char *digit[] = { ! 8: "-----", ! 9: ".----", ! 10: "..---", ! 11: "...--", ! 12: "....-", ! 13: ".....", ! 14: "-....", ! 15: "--...", ! 16: "---..", ! 17: "----.", ! 18: 0 ! 19: }; ! 20: ! 21: char *alph[] = { ! 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: 0}; ! 49: ! 50: main() { ! 51: ! 52: register c; ! 53: ! 54: while ((c = getchar()) != EOF) { ! 55: if (isupper(c)) ! 56: c = tolower(c); ! 57: if (isalpha(c)) ! 58: print(alph[c-'a']); ! 59: else if (isdigit(c)) ! 60: print(digit[c-'0']); ! 61: else if (c == ',') ! 62: print("--..--"); ! 63: else if (c == '.') ! 64: print(".-.-.-"); ! 65: else if (isspace(c)) ! 66: printf(" ...\n"); ! 67: } ! 68: } ! 69: ! 70: print(s) char *s; { ! 71: char *p; ! 72: for (p = s; *p; p++) ! 73: if (*p == '.') ! 74: printf(" %s", dit); ! 75: else if (*p == '-') ! 76: printf(" %s", daw); ! 77: printf(",\n"); ! 78: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.