-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfeibiao.c
113 lines (111 loc) · 2.21 KB
/
feibiao.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// 将呼号转换成非标准字母解释法的单词组合的C程序
// 用法:
// $ gcc -Wall -Wpedantic -Wextra -std=c99 -o feibiao feibiao.c
// $ ./feibiao
// 特别鸣谢:ChatGPT
#include <stdio.h>
#include <ctype.h>
#include <string.h>
const char* natoTranslate(char c)
{
switch (toupper(c))
{
case 'A':
return "America";
case 'B':
return "Beta";
case 'C':
return "Canada";
case 'D':
return "Denmark";
case 'E':
return "England";
case 'F':
return "Florida";
case 'G':
return "Germany";
case 'H':
return "Honolulu";
case 'I':
return "Italy";
case 'J':
return "Japan";
case 'K':
return "Kilowatt";
case 'L':
return "London";
case 'M':
return "Mexico";
case 'N':
return "Norway";
case 'O':
return "Ontario";
case 'P':
return "Peter";
case 'Q':
return "Queen";
case 'R':
return "Radio";
case 'S':
return "Sugar";
case 'T':
return "Tokyo";
case 'U':
return "United";
case 'V':
return "Video";
case 'W':
return "Washington";
case 'X':
return "X-ray";
case 'Y':
return "Yokohama";
case '0':
return "Zanzibar";
case '1':
return "One";
case '2':
return "Two";
case '3':
return "Three";
case '4':
return "Four";
case '5':
return "Five";
case '6':
return "Six";
case '7':
return "Seven";
case '8':
return "Eight";
case '9':
return "Nine";
case '/':
return "Portable";
default:
return 0;
}
}
int main(void)
{
printf("请输入要翻译的呼号:");
char ch[64];
int i;
if (fgets(ch, 64, stdin))
{
ch[strcspn(ch, "\n")] = 0;
}
for (i = 0; ch[i] != '\0'; i++)
{
if (isalnum(ch[i]) || ch[i] == '/')
printf("%c", ch[i]);
}
printf("的字母解释法是:");
for (i = 0; ch[i] != '\0'; i++)
{
if (isalnum(ch[i]) || ch[i] == '/')
printf("%s ", natoTranslate(ch[i]));
}
printf("\n");
return 0;
}