c语言的翻译叫什么_C语言实现翻译功能

本文实例为大家分享了C语言实现翻译功能的具体代码,供大家参考,具体内容如下

#include

#define number 100

struct date

{

char chinese[30];

char English[30];

}a[number];

void copy(char *str1, char *str2, int counst)//将值赋给trans

{

int i = 0;

if (str2 == ' ' || str2 == '\0')

{

return;

}

while (counst--)

{

*str1++ = *str2++;

}

return;

}

int panduan(char *d, char *f)//判断是否相等

{

char *str1 = d, *str2 = f;

int xc=0;

while (!(xc = *str2 - *str1)&&*str1)

{

str1++;

str2++;

}

if (xc != 0)

{

return 0;

}

return 1;

}

char* ry( struct date a[number],char *wordtemp,int x)

{

for (int i = 0;i

{

if (panduan(a[i].English, wordtemp))

{

return a[i].chinese;

}

}

return "NULL";

}

int main()

{

char b;

int x;

int exit=0;

char str[50];

printf("[请先输入英文单词,再输入拼音,中间以空格隔开,当输入*时结束]\n");

for (int i=0;; i++)

{

printf("第[%d]组:\t", i+1);

scanf("%[^' ']", a[i].English);

scanf("%c", &b);

scanf("%[^\n]", a[i].chinese);

scanf("%c", &b);

if (*a[i].English == '*'&&*a[i].chinese == '*')

{

x = i;

break;

}

}

printf("[请输入你所要翻译的内容]\n");

scanf("%[^\n]", str);

printf("|翻译的结果为|:\n");

for (int i = 0;; i++)

{

if (str[i] != ' ')

{

char Trans[100];

int n = 0;

if(str[i]!=' ')

{

while (!(str[i] == ' ' || str[i] == '\0'))

{

n++;

i++;

if (str[i] == '\0')

{

exit = 1;

}

}

copy(Trans, &str[i - n], n);

Trans[n] = '\0';

printf("[%s]", ry(a,Trans,x));

}

if (exit)

{

break;

}

}

}

system("pause");

}

f57c15161983dda52c622d2714472ddf.png

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值