113 lines
2.0 KiB
C
113 lines
2.0 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int letters_size = 26;
|
|
char letters[][6] = {
|
|
".-", //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
|
|
};
|
|
int num_size = 10;
|
|
char numbers[][6] = {
|
|
"-----", //0
|
|
".----", //1
|
|
"..---", //2
|
|
"...--", //3
|
|
"....-", //4
|
|
".....", //5
|
|
"-....", //6
|
|
"--...", //7
|
|
"---..", //8
|
|
"----.", //9
|
|
};
|
|
|
|
void print_char(char word[])
|
|
{
|
|
if(strlen(word)==0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for(int i=0; i<letters_size; i++)
|
|
{
|
|
if(strcmp(word, letters[i])==0)
|
|
{
|
|
printf("%c", i+65);
|
|
return;
|
|
}
|
|
}
|
|
for(int i=0; i<num_size; i++)
|
|
{
|
|
if(strcmp(word, numbers[i])==0)
|
|
{
|
|
printf("%c", i+48);
|
|
return;
|
|
}
|
|
}
|
|
printf("#");
|
|
}
|
|
|
|
int main()
|
|
{
|
|
int size=0;
|
|
char word[20];
|
|
char c;
|
|
while(1)
|
|
{
|
|
if (scanf("%c", &c)==EOF)
|
|
{
|
|
word[size]=0;
|
|
print_char(word);
|
|
break;
|
|
}
|
|
if(c==' ')
|
|
{
|
|
word[size]=0;
|
|
print_char(word);
|
|
size=0;
|
|
}
|
|
else if(c=='/')
|
|
{
|
|
printf(" ");
|
|
}
|
|
else if(c=='\n')
|
|
{
|
|
if (size!=0)
|
|
{
|
|
word[size]=0;
|
|
print_char(word);
|
|
size=0;
|
|
|
|
}
|
|
printf("\n");
|
|
}
|
|
else
|
|
{
|
|
word[size]=c;
|
|
size++;
|
|
}
|
|
}
|
|
} |