用C语言编写一个中译英、英译中的程序

来源:百度知道 编辑:UC知道 时间:2024/05/24 13:27:41
最好是用上指针和数组
#include<stdio.h>
#include<string.h>
#define NUM 5

char* ENG[NUM]={"annually","festival","saint","cash","typical"};
char* CHN[NUM]={"一年一次地","节日","圣人","现金","典型的"};

int main( void )
{
char c[100];
do
{
printf("\nEnter a word:");
gets(c);

int i;
for(i=0; i<NUM; i++)
{
if(strcmp(c, ENG[1])==0)
{
printf("\nEnglish %s,translates for: %s", c, CHN[1]);
break;
}
}

if(i==NUM)
printf("\nThe dictionary don't have this word");

char ch;
printf("\nDo you want to contin

改好了:
#include<stdio.h>
#include<string.h>
#define NUM 5

char* ENG[NUM]={"annually","festival","saint","cash","typical"};
char* CHN[NUM]={"一年一次地","节日","圣人","现金","典型的"};

int main( void )
{
char c[100];
do
{
printf("\nEnter a word:");
gets(c);

int i;
for(i=0; i<NUM; i++)
{
if(strcmp(c, ENG[i])==0)
{
printf("\nEnglish %s,translates for: %s", c, CHN[i]);
break;
}
}

if(i==NUM)
printf("\nThe dictionary don't have this word");

char ch;
printf("\nDo you want to continue(Y/N)");
scanf("%c", &ch);
if(ch!='y' || ch!='Y')
break;
}while(1);

return 0;
}

if(strcmp(c, ENG[1])==0)