C语言关键字中英翻译机(只是翻译C语言中的关键字)。求高手帮忙......
要求输入中文的名词和关键字,可以将其翻译成英语,如输入“基本整形”+回车,得到int;输入英文的单词int,则可以翻译成中文“基本整形”。可模拟文曲星来实现。可多次查询,...
要求输入中文的名词和关键字,可以将其翻译成英语,如输入“基本整形”+回车,得到int;输入英文的单词int,则可以翻译成中文“基本整形”。可模拟文曲星来实现。可多次查询,输入bye时退出。
展开
2个回答
展开全部
#include<stdio.h>
#include<string.h>
char* bijiao(char* s1,char* s2[],char* s3[])
{
int i,j;
for(i=0;i<32;i++)
{
for(j=0;j<(int)strlen(s2[i]);j++)
{
if(s1[j]!=s2[i][j]) break;
}
if(j==(int)strlen(s2[i]))
return s3[i];
for(j=0;j<(int)strlen(s3[i]);j++)
{
if(s1[j]!=s3[i][j]) break;
}
if(j==(int)strlen(s3[i]))
return s2[i];
}
return "没有找到数据";
}
void main()
{
char str[50];
char* str1[32]={"auto","break","case","char","const","continue","default"
,"do","double","else","enum","extern","float","for","goto","if","int"
,"long","register","return","short","signed","static","sizeof","struct"
,"switch","typedef","union","unsigned","void","volatile","while"};
char* str2[32]={"自动变量","跳出当前循环","开关语句分支","字符型变量","只读变量","结束当前循环","其他分支"
,"循环语句的循环体","双精度变量","条件语句否定分支","枚举类型","声明变量是在其他文件正声明","浮点型变量","循环语句","跳转语句","条件语句","整型变量"
,"长整型变量","寄存器变量","返回语句","短整型变量","有符号类型变量","静态变量","计算数据类型长度","结构体变量"
,"开关语句","用以给数据类型取别名","共用数据类型","无符号类型变量","无返回值","说明变量在程序执行中可被隐含地改变","循环语句的循环条件"};
while(1)
{
gets(str);
if(str[0]=='b'&&str[1]=='y'&&str[2]=='e'&&str[3]=='\0')return ;
puts(bijiao(str,str1,str2));
printf("\n");
}
}
#include<string.h>
char* bijiao(char* s1,char* s2[],char* s3[])
{
int i,j;
for(i=0;i<32;i++)
{
for(j=0;j<(int)strlen(s2[i]);j++)
{
if(s1[j]!=s2[i][j]) break;
}
if(j==(int)strlen(s2[i]))
return s3[i];
for(j=0;j<(int)strlen(s3[i]);j++)
{
if(s1[j]!=s3[i][j]) break;
}
if(j==(int)strlen(s3[i]))
return s2[i];
}
return "没有找到数据";
}
void main()
{
char str[50];
char* str1[32]={"auto","break","case","char","const","continue","default"
,"do","double","else","enum","extern","float","for","goto","if","int"
,"long","register","return","short","signed","static","sizeof","struct"
,"switch","typedef","union","unsigned","void","volatile","while"};
char* str2[32]={"自动变量","跳出当前循环","开关语句分支","字符型变量","只读变量","结束当前循环","其他分支"
,"循环语句的循环体","双精度变量","条件语句否定分支","枚举类型","声明变量是在其他文件正声明","浮点型变量","循环语句","跳转语句","条件语句","整型变量"
,"长整型变量","寄存器变量","返回语句","短整型变量","有符号类型变量","静态变量","计算数据类型长度","结构体变量"
,"开关语句","用以给数据类型取别名","共用数据类型","无符号类型变量","无返回值","说明变量在程序执行中可被隐含地改变","循环语句的循环条件"};
while(1)
{
gets(str);
if(str[0]=='b'&&str[1]=='y'&&str[2]=='e'&&str[3]=='\0')return ;
puts(bijiao(str,str1,str2));
printf("\n");
}
}
语言桥
2024-04-03 广告
2024-04-03 广告
选择一家专业的翻译公司,对于确保翻译质量和效率至关重要。以下是几个建议,帮助您做出明智的选择:首先,审查翻译公司的资质和声誉。一个专业的翻译公司通常具备相应的行业认证和资质,这可以作为其专业能力的初步证明。同时,您可以查阅客户评价、行业评级...
点击进入详情页
本回答由语言桥提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询