#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
typedef struct {
char english[50];
char chinese[50];
} WordTranslation;
int main() {
int x;
int n, g = 1;
while (g) {
n = 0;
WordTranslation translations[] = {
{“apple”, “苹果”},
{“banana”, “香蕉”},
{“orange”, “橙子”},
{“dog”, “狗”},
{“cat”, “猫”}
};
int numTranslations = sizeof(translations) / sizeof(WordTranslation);
char inputWord[50];
printf("\n\n请输入要翻译的单词: ");
scanf("%s", inputWord);
int found = 0;
for (int i = 0; i < numTranslations; i++) {
if (strcmp(inputWord, translations[i].english) == 0) {
printf("%s 的翻译是: %s\n\n", inputWord, translations[i].chinese);
found = 1;
break;
}
}
if (!found) {
printf("未找到 %s 的翻译\n", inputWord);
}
printf("\n\nWanna continue想继续吗? 1.continue继续 0.exit退出\n");
scanf("%d", &g);
}
return 0;
}