您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 企业财务 > 一种简单的英文词典排版系统.
中国地质大学(武汉)C语言课程设计论文学院:工程学院专业:勘察技术与工程题目:一种简单的英文词典排版系统班级:54073姓名:学号:200710031882009年1月摘要I一种简单的英文词典排版系统摘要在英文词典排版当中,人工统计的速度很慢,且容易出现差错。本英文词典排版系统的自动化加速了排版工作,提高工作效率本程序主要采用对零散的单词进行自动读取,然后按单词首字母顺序讲单词保存到文档,这样的结构化非常便于程序后续的排版工作。排版具体过程涉及到自动排除重复单词与添加新单词并重新排版等问题,将于正问中详细介绍。本程序实现了所有设计要求。关键词:英文词典排版系统,结构体,排版,单词1目录中文摘要············································································Ⅰ主要符号表·········································································Ⅳ1题目要求····························································································11.1....................................................................................................................................12需求分析·····························································································3总体设计·····························································································4详细设计·····························································································4.1主函数···························································································4.2各功能模块设计···············································································5.运行结果(附带抓图)···········································································6.总结·······························································································································································································································································································································参考文献··································································································致谢········································································································2主要符号表#includestdlib.h---为exit()函数提供原型;#includestring.h---字符串处理函数原型;#includectype.h---字符处理函数原型;#defineROWS256#defineCOLS32---定义“字典”的大小:可存放256个单词,每个单词的长度不超过31staticFILE*fp;---定义文件指针:内部链接,文件作用域;staticchara[ROWS][COLS];---定义数组:内部链接,文件作用域;该数组的作用是将文件的内容复制进来,并加以处理。因为处理数组比处理文件方便。charget_option(void);---接收用户的选项,防止误操作。若输入“a;”(不包括引号),那么将视为选项aintb(intcount);---完成选项b的作用--接收新单词;voidc(char*pt[],intcount);---完成选项c的作用--通过指针对数组排序,实际数组元素位置未改变;intcheck(chararr[],intcount);---对输入的单词进行分辨,若输入nihao,将视为单词ni,并且提示并剔除重复的单词;voidstorage(char*pt[],intcount);---在程序结束之前重新排序存储数组中的单词到文件中。31题目要求1.能输入和显示打入的单词2.能分辨出单词3.对重复的单词和已经输入的单词能自动排除4.能按A—Z的顺序排版5.能将运行结果以文本形式存储6.具有添加新单词并重新排版的能力7.数据结构采用指针数组或二维数组。以回车键或者空格键作为单词输入结束标志,对重复的单词自动排除可选第一张提到的查找方法,数据结构可采用指针和数组2需求分析运行结果以文本形式存储,因而要提供文件的输入输出操作;通过查找操作检查重复单词;提供排序操作系统实现按A—Z的顺序排版;提供插入操作添加新单词并重新排版。另外通过键盘式菜单实现功能选择。3总体设计整个系统呗设计为单词录入模块、文件存储模块和单词浏览模块。其中单词录入模块要完成输入单词、检查是否重复、排序操作。文件存储模块把存放单词的数组中的数据写入文件。单词浏览模块完成英文词典的输出,即文件的输出操作。系统功能模块图:一种简单的英文词典排版系统单词录入单词浏览单词排序删除单词单词存储添加单词44详细设计1.主函数【流程图】NY【程序】#includestdio.h#includestdlib.h#includestring.h#includectype.h#defineROWS256#defineCOLS32staticFILE*fp;staticchara[ROWS][COLS];charget_option(void);intb(intcount);voidc(char*pt[],intcount);intcheck(chararr[],intcount);voidstorage(char*pt[],intcount);intn;//****n全局变量*****//charword[N][20];voidmenu()//***主界面***//{intn,w;//*变量n保存选择菜单数字,w判断输入的数字是否在功能菜单对应数字范围内*//do{puts(\t\t********************MENU********************\n\n);puts(\t\t\tWelcometodj'sprogram!\n\n);puts(\t\t\t\t1.Addnewword.);显示一系列的功能选项输入n,判断n是否是1—9根据n的值调用各功能模块函数5puts(\t\t\t\t2.Browseallthewords.);puts(\t\t\t\t3.Searchtheword.);puts(\t\t\t\t4.Sortthewords.);puts(\t\t\t\t5.OrderbyA-z.);puts(\t\t\t\t6.Exit!);puts(\n\n\t\t****************************************\n);printf(Choiceyournumber(1-6):[]\b\b);scanf(%d,&n);if(n1||n6)//*对选择的数字作判断*//{w=1;getchar();}elsew=0;}while(w==1);switch(n){case1:add();break;//*追加模块*//case2:browse();break;//*浏览模块*//case3:search();break;//*查找模块*//case4:sort();break;//*分类模块*//case5:order();break;//*排序模块*//case6:exit(0);//*退出*//}}voidmain()//********主函数*********//{menu();}2.公共函数【程序】intload()//*加载函数*//{inti,count;intstart;char*pt[ROWS];charch,len;charinput;if((fp=fopen(words.txt,a+))==NULL)//*以输出打开方式,在此前的记录被覆盖*//{printf(\nCannotopenfile!\n);6returnNULL;}for(i=0;!feof(fp);i++)fscanf(fp,%s,&word[i]);fclose(fp);returni+1;//*返回记录个数*//}voidsave(intn)//*保存函数,保存n个记录*//{FILE*fp;inti;if((fp=fopen(words.txt,a+))==NULL)//*以输出打开方式,在此前的记录被覆盖*//{printf(\nCannotopenfile!\n);exit(0);}for(i=0;in;i++)fprintf(fp,%s,&word[i]);fclose(fp);}3.各功能模块设计1)分类模块【程序】voidsort(){inti,j,k;charc[20];if((n=load())==0){printf(\nCannotopenfile!\n);exit(0);}for(i=0;in;i++)for(j=0;jn-i-1;j++);if(strcmp(word[j],word[j+1])0){strcmp(c,word[j]);strcmp(word[j],word[j+1]);strcmp(word[j+1],c);}save(n);7printf(Successful!^_^.\n);printf(\nNow?1.browseall2.back);scanf(%d,&k);if(k==1)browse();elseif(k==2)menu();}2)排序模块【流程图】【程序】voidorder()//*排序模块*//{inta[N],i,j,t;structwords;n=load();for(i=0;iN;i++)for(i=0;iN-1;i++)for(j=i+i;jN;j++)if(a[i]a[j]){t=a[i];a[i]=a[j];a[j]=t;}for(j=0;jN;j++)printf(%3d,a[i]);}用选择法排序保存返回主菜单83)修改模块【流程图】YNYY【程序】voidmodify(inta)//*修改模块*//{charc[20];printf(Enterthenewword:);scanf(%s,c);strcpy(word[
本文标题:一种简单的英文词典排版系统.
链接地址:https://www.777doc.com/doc-6221066 .html