C++课程设计之电子词典-CAL-FENGHAI-(2020YEAR-YICAI)_JINGBIAN仲恺农业工程学院工程实训报告电子词典课程名称C++面向对象课程设计姓名郑志欣院(系)信息科学与技术学院专业班级计算机科学与技术132班学号 4215指导教师史婷婷仲恺农业工程学院教务处制目录1 需求分析........................................................................................................................ 错误!未定义书签。
2 系统总框图和功能模块说明 ........................................................................................ 错误!未定义书签。
系统总框图 ............................................................................................................. 错误!未定义书签。
功能模块说明 ......................................................................................................... 错误!未定义书签。
3 系统设计........................................................................................................................ 错误!未定义书签。
主要结构体.............................................................................................................. 错误!未定义书签。
主要功能函数........................................................................................................... 错误!未定义书签。
关键函数的流程图.................................................................................................. 错误!未定义书签。
4 系统调试........................................................................................................................ 错误!未定义书签。
5 总结................................................................................................................................ 错误!未定义书签。
6 源程序清单 .................................................................................................................... 错误!未定义书签。
1 需求分析在这个电子词典系统里,我主要是作为一个英汉词典进行,该系统具备简单的英汉词典的功能,使之能提供以下功能: 单词查找 单词增除单词修改、维护等工作2 系统总框图和功能模块说明系统总框图功能模块说明增加单词,完成单词录入;查找单词,完成单词输出;电子词典系统单词查找 单词增加 单词删除单词修改保存词典根据英文查询根据中文查询3 系统设计""""电子词典源代码#include<>#include<>#include<>#include<>void main(){static int n=13;char m;struct{char eng[50];char ci[50];char yin[50];char chi[50];}word[1000]={{"cat","n","猫"},{"clean","adj&d&v","1.干净 2.整洁"}, {"finally","ad","最终,终于"},};int();loop:for(;;){system("cls");int();cout<<"\n\t==========欢迎进入英汉词典=========="<<endl; cout<<"\n\t ****选择项目**** \n"<<endl;cout<<"\n\n\t 1.增加单词\n"<<endl;cout<<"\t 2.删除单词\n"<<endl;cout<<"\t 3.查找单词\n"<<endl;cout<<"\t 4.修改单词\n"<<endl;cout<<"\t 5.退出系统\n\n"<<endl;cout<<" 请选择1~5选项\n"<<endl;cout<<" Please press the key:";cin>>m;switch(m){case '1':{char j[10],k[15],l[10],p[30];++n;cout<<"\n 增加单词"<<endl;cout<<"\n\n 请输入单词:";cin>>j;cout<<"\n 输入词性:";cin>>k;cout<<"\n 输入中文:";cin>>l;strcpy(word[n].eng,j);strcpy(word[n].ci,k);strcpy(word[n].yin,l);cout<<"\n Please check it:";cout<<"\n\n 英文: "<<word[n].eng<<endl; cout<<"\n\n 词性: "<<word[n].ci<<endl; cout<<"\n\n 中文: "<<word[n].yin<<endl; cout<<"\n 按任意键返回"<<endl; cin>>m;}break;case '2':{char r[10];int s,t,z=0,x=0;cout<<"\n 请输入你要删除的单词:"; cin>>r;for(s=0;s<=n;s++){if(s<=n-1){if(strcmp(word[s].eng,r)==0){x=1;for (t=s;t<n;t++){strcpy(word[t].eng,word[t+1].eng);strcpy(word[t].ci,word[t+1].ci);strcpy(word[t].yin,word[t+1].yin);}}}else{if(strcmp(word[n].eng,r)==0)z=1;elsez=0;}}if(z==1||x==1){cout<<"\n\n 删除成功! \n"<<endl;n--;cout<<"\n 按任意键返回"<<endl; cin>>m;}else{cout<<"\n\n 删除失败"<<endl;cout<<"\n 按任意键返回"<<endl; cin>>m;}}break;case '3':{int l;cout<<"\n\n 查找单词 \n"<<endl; cout<<" 1.通过英文查找 \n"<<endl; cout<<" 2.通过中文查找 \n"<<endl; cout<<" 请选择:";cin>>l;switch(1){case 1:{char r[10],m[1]; int s;cout<<"\n 请输入所要查找的英文:"; cin>>r;for(s=0;s<=n;s++){if(s<=n-1)if(strcmp(word[s].eng,r)==0)break;elsecontinue;elseif(strcmp(word[n].eng,r)==0)break;else{char m[1];cout<<"\n 按任意键返回"<<endl;cin>>m;goto loop;}}cout<<"\n\n 英文: "<<word[s].eng<<endl; cout<<"\n\n 词性: "<<word[s].ci<<endl; cout<<"\n\n 中文: "<<word[s].yin<<endl; cout<<"\n 按任意键返回"<<endl; cin>>m;break;}case 2:{char r[10],m[1]; int s;cout<<"\n 请输入所要查找的中文:"; cin>>r;for(s=0;s<=n;s++){if(s<=n-1)if(strcmp(word[s].chi,r)==0)break;elsecontinue;elseif(strcmp(word[n].chi,r)==0)break;else{char m[1];cout<<"\n 按任意键返回"<<endl; cin>>m;goto loop;}}cout<<"\n 英文: "<<word[s].eng<<endl; cout<<"\n\n 词性: "<<word[s].ci<<endl; cout<<"\n\n 中文: "<<word[s].yin<<endl; cout<<"\n 按任意键返回"<<endl; cin>>m;break;}}case '4':{char j[10],k[15],l[10],p[30],r[10],m[1];int s;++n;cout<<"\n 修改单词 "<<word[s].eng<<endl;cout<<"\n\n 请输入你行更改的单词:";cin>>r;for(s=0;s<=n;s++){if(s<=n-1)if(strcmp(word[s].eng,r)==0)break;elsecontinue;elseif(strcmp(word[n].eng,r)==0)break;else{char m[1];cout<<"\n 没有这个单词!!\n 按任意键返回"<<endl; cin>>m;goto loop;}}cout<<"\n\n 英文: "<<word[s].eng<<endl;cout<<"\n\n 词性: "<<word[s].ci<<endl;cout<<"\n\n 中文: "<<word[s].yin<<endl;cout<<"\n\n 你可以进行修改"<<endl;cout<<"\n 请输入单词:";cin>>j;cout<<"\n 请输入词性:";cin>>k;cout<<"\n 请输入中文:";cin>>l;strcpy(word[n].eng,j);strcpy(word[n].ci,k);strcpy(word[n].yin,l);cout<<"\n 确认";cout<<"\n\n 英文: "<<word[n].eng<<endl;cout<<"\n\n 词性: "<<word[n].ci<<endl;cout<<"\n\n 中文: "<<word[n].yin<<endl;cout<<"\n 按任意键返回"<<endl;cin>>m;}break;case '5':exit(1);break;}}}}4 系统调试开始菜单增加单词删除单词查找单词修改单词退出系统5 总结这次编程里,遇到几次数组溢出,原因是自己在开头没做好6 源程序清单。