C语言实现简单的翻译功能
2018年04月25日 16:48:30 火炎焱燚OOK 阅读数 3813
题目描述:编写一个程序,依次输入英文与汉语拼音,输入两个“ * ”表示输入结束,再输入一段英语句子,打印出其对应汉语拼音。
要求:不得使用
题目中要求不得使用
#include
下面是程序示例:
/*输出学生详细信息*/
void output(const Student* sa) {
int index;
printf("学生详细信息:\n");
printf("学号\t\t姓名\t性别\t班级\t数学\t英语\t物理\n");
for (index = 0; index < STUDENT_COUNT; ++index) { //共输出STUDENT_COUNT条学生的信息
const Student* s = &sa[index]; //获取第indexts记录的地址
outputStudent(s); //输出该条信息
}
}
/*通过学号查找学生信息*/
void findByID(const Student* sa) {
int index;
char id[128];
const Student* target = NULL; //初始化未找到时为NULL
printf("请输入要查找的学生学号:\n");
scanf("%s", id); //输入要查找的学生学号
printf("学号\t\t姓名\t性别\t班级\t数学\t英语\t物理\n"); //输出标题
for (index = 0; index < STUDENT_COUNT; ++index) { //在所有学生记录中查找
const Student* s = &sa[index]; //获取第index条记录的首地址
if (strcmp(s->id, id) == 0) { //若记录中的id与要查找的id完全相同
target = s; //就记录该记录的地址
break; //然后提前退出循环
}
}
if (target) { //target不是NULL,说明是找到了
outputStudent(target); //就调用输出函数,输出此学生信息
} else {
printf("未找到该学号的相关信息。\n"); //否则输出“未找到”信息
}
}