安卓版c语言英汉翻译词典代码

59 阅读1分钟

#include <stdio.h> #include <string.h>

// 定义单词和翻译的结构体 typedef struct { char english[50]; char chinese[50]; } WordTranslation;

int main() { WordTranslation translations[] = { {"abandon", "v.抛弃,放弃"}, {"abandonment", "n.放弃"}, {"abbreviation", "n.缩写"}, {"yell", "v.,n.叫嚷"}, {"yellow", "n.,adj.黄色(的"}, {"yes", "ndv.是,好"}, {"yesterday", "n.昨天 adv.在昨天"}, {"yet", "ndv.仍然,还,尚"}, {"yield", "v.生产,屈服 n.产量"}, {"yoke", "n.轭"}, {"yolk", "n.蛋黄"}, {"you", "pron.你,你们"}, {"young", "ndj.年轻的 n.青年人"}, {"youngster", "n.少年"}, {"your", "pron.你的,你们的"}, {"yourself", "pron.你(们自己"}, {"youth", "n.青春,青年"}, {"youthful", "ndj.年轻的"}, {"zeal", "n.热情,热忱"}, {"zealous", "ndj.热情的,热心的"}, {"zebra", "n.斑马"}, {"zero", "n.零,零度"}, {"zinc", "n.锌"}, {"zip", "n.活动,尖啸声"}, {"zipcode", "n.邮政编码"}, {"zipper", "n.拉链"}, {"zone", "n.地带,区域,区"}, {"zoo", "n.动物园"}, {"zoology", "n.动物学"}, };

int numTranslations = sizeof(translations) / sizeof(WordTranslation);

char inputWord[50];
printf("请输入要翻译的单词: ");
scanf("%s", inputWord);

int found = 0;
for (int i = 0; i < numTranslations; i++) {
    if (strcmp(inputWord, translations[i].english) == 0) {
        printf("%s 的翻译是: %s\n", inputWord, translations[i].chinese);
        found = 1;
        break;
    }
}

if (!found) {
    printf("未找到 %s 的翻译\n", inputWord);
}

return 0;

}