成语大全网 - 汉语词典 - 中英词典编写c

中英词典编写c

#include?<stdio.h>

#include?<string.h>

char?*weeks[]={"Monday","Tuesday","Wednesday","Thursday","Friday",

"Saturday","Sunday"};

char?*trans[]={"星期一","星期二","星期三","星期四","星期五","星期六","星期日"};

void?translate(char?*pstr)

{

int?i;

for(i=0;i<7;i++)

{

if(strcmp(weeks[i],pstr)?==?0)

{

printf("%s中文意思为%s\n",weeks[i],trans[i]);

break;

}

}

}

int?main()

{

char?str[64];

printf("请输入要翻译的单词:");

scanf("%s",str);

translate(str);

return?0;

}

示例运行结果:

请输入要翻译的单词:Wednesday

Wednesday中文意思为星期三