版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
设计目标《数据结构》课程关键介绍最常见数据结构,说明多种数据结构内在逻辑关系,讨论其在计算机中存放表示,和在其上进行多种运算时实现算法,并对算法效率进行简单分析和讨论。进行数据结构课程设计要达成以下目标:了解并掌握数据结构和算法设计方法,含有初步独立分析和设计能力;初步掌握软件开发过程问题分析、系统设计、程序编码、测试等基础方法和技能;提升综合利用所学理论知识和方法独立分析和处理问题能力;训练用系统见解和软件开发通常规范进行软件开发,培养软件工作者所应含有科学工作方法和作风。设计内容和要求关键分为两大功效:(1)图书管理(增加图书、查询图书、删除图书、图书借阅、还书);(2)会员管理(增加会员、查询会员、删除会员、借书信息)。设计要求:(1)符合课题要求,实现对应功效;(2)要求界面友好美观,操作方便易行;(3)注意程序实用性、安全性;3.本设计所采取数据结构采取两条单链表,其头结点分别为head、mhead全局变量来存放图书信息和会员信息。其定义数据结构以下:/*图书信息结构体*/typedefstructelem{ charbookid[5]; charbookname[50]; charbookauthor[20]; charbookmark[2]; charmemberid[4]; }elemtype;/*图书链表结点结构体*/typedefstructnode{ elemtypedata; structnode*next; }lnode,*linknode;/*会员信息结构体*/typedefstructmemberelem{ charmemberid[4]; charmembername[20]; }memberelemtype;/*会员链表结点结构体*/typedefstructmembernode{ memberelemtypedata; structmembernode*next; }mlnode,*mlinknode;4.功效模块具体设计图书借阅管理系统图书借阅管理系统图书管理模块会员管理模块增加图书查询图书删除图书图书借阅还书增加会员查询会员借书信息删除会员4.1具体设计思想系统开启时,经过读取文件完成对以head、mhead为表头单链表完成初始化。初始化后系统进入系统菜单,其运行界面以下:当选择功效1时,进入图书管理模块,其运行界面以下:当选择功效2时,进入会员管理模块,其运行界面以下:在图书管理界面中,当选择功效1时,查看全部图书,其运行界面图:在会员管理界面中,当选择功效1时,查看全部会员,其运行界面图:4.2各个实现函数为了实现上述功效,特定义以下函数原型,具体代码参见源代码部分:voidmain()/*入口*/voidinitallinfo()/*初始化图书和会员链表*/voidwelform()/*系统总菜单*/voidprintbookinfo(linknodehead)/*输出图书信息函数*/voidaddbook()/*增加图书模块*/voidselect()/*按编号查询图书*/voiddelete()/*按编号删除图书*/voidborrow()/*借阅图书*/voidreturnbook()/*还书*/voidbookmanagetitle()/*图书管理二级菜单*/voidbookmanage()/*二级图书管理功效选择函数*/voidprintmemberinfo(mlinknodehead)/*输出会员信息函数*/voidaddmember()/*增加会员模块*/voidselectmember()/*按编号查询会员*/voiddeletemember()/*按编号删除会员*/voidmembermanagetitle()/*会员管理二级菜单*/voidmembermanage()/*二级会员管理功效选择函数*/4.4图书会员链表程序调试数据如表:图书初始数据表bookidbooknamebookauthorbookmarkmemberid0001sanguoyanyiluoguanzhongN00002hongloumengcaoxueqinN00003xiyoujiwuchengenY0010004shuihuzhuanshinaianN00005javascriptJoinN00006cprogromtanghaoqiangN00007liaozhaizhiyipusonglingY0070008jiabajinN00009richucaoyuY0030010nahanluxunN0会员信息表memberidmembername001zhouxicai002longqidong003lipengfei004gaopeng005chenwentang006yangminghao4.5关键代码#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<string.h>#defineNULL0typedefstructelem{ charbookid[5]; charbookname[50]; charbookauthor[20]; charbookmark[2]; charmemberid[5];}elemtype;typedefstructnode{ elemtypedata; structnode*next;}lnode,*linknode;typedefstructmemberelem{ charmemberid[5]; charmembername[25];}memberelemtype;typedefstructmembernode{ memberelemtypedata; structmembernode*next;}mlnode,*mlinknode;linknodehead;mlinknodemhead;FILE*bp,*bq;voidinitallinfo(){ FILE*bp,*bq; linknodep,q; mlinknodem,n; head=(lnode*)malloc(sizeof(lnode)); head->next=NULL; mhead=(mlnode*)malloc(sizeof(mlnode)); mhead->next=NULL; bp=fopen("book.txt","rb"); printf("%s",feof(bp)); bq=fopen("member.txt","rb"); printf("%s",feof(bp)); if(bp==NULL) { printf("cannotopenbookbat!"); getchar(); getchar(); } else { do { p=(lnode*)malloc(sizeof(lnode)); fread(p,sizeof(lnode),1,bp); q=p->next; p->next=head->next; head->next=p; }while(q!=NULL); fclose(bp); } if(bq==NULL) { printf("cannotopenmemberdat!"); getchar(); getchar(); } else { do { m=(mlnode*)malloc(sizeof(mlnode)); fread(m,sizeof(mlnode),1,bq); n=m->next; m->next=mhead->next; mhead->next=m; }while(n!=NULL);fclose(bq); }}voidmainmenu(){ system("cls"); printf("SYSTEMMAINMENU\n"); printf("*********************************************\n"); printf("*1:bookmanage*\n"); printf("*-------------------------------------------*\n"); printf("*2:membermanage*\n"); printf("*-------------------------------------------*\n"); printf("*0:quit*\n"); printf("*********************************************\n"); printf("\nPleaseinputorder:\n");}voidprintbookinfo(linknodehead){ linknodep=head->next; system("cls"); printf("Thebookinformationsare:\n"); printf("%-7s%-20s%-15s%-6s%s\n","id","title","author","mark","borrower"); printf("*********************************************\n"); for(;p!=NULL;p=p->next) printf("%-7s%-20s%-15s%-6s%s\n",p->data.bookid,p->data.bookname,p->data.bookauthor,p->data.bookmark,p->data.memberid); printf("\nPleaseanykeyreturn....."); getchar(); getchar();}voidaddbook(){ linknodep=(lnode*)malloc(sizeof(lnode)); system("cls"); printf("Addbooks.....\n"); printf("%-7s%-20s%-15s%\n","id(5)","title","author"); printf("*********************************************\n"); scanf("%s%s%s",p->data.bookid,p->data.bookname,p->data.bookauthor); p->data.bookmark[0]='N'; p->data.bookmark[1]='\0'; p->data.memberid[0]='0'; p->data.memberid[1]='\0'; p->next=head->next; head->next=p; printf("\nAddsuccess!\n"); printf("\nPressanykeyreturn....."); getchar(); getchar();}voidselect(){ charid[5]; linknodep; system("cls"); p=head->next; printf("selectbookbyid.....\n"); printf("Pleaseinputbookid:\n"); scanf("%s",id); while(p!=NULL) { if(strcmp(p->data.bookid,id)==0) break; else p=p->next; } if(p==NULL) printf("\nThebooknotexit!\n"); else { printf("\n%-7s%-20s%-15s%-3s%s\n","id","title","author","borrowed","borrower"); printf("********************************************\n"); printf("\n%-7s%-20s%-15s%-3s%s\n",p->data.bookid,p->data.bookname,p->data.bookauthor,p->data.bookmark,p->data.memberid); } printf("\nPleaseanykeyreturn....."); getchar(); getchar();}voiddeletebook(){ charid[5]; linknodep,q; system("cls"); p=head->next; q=head; printf("deletebookbyid......\n"); printf("Pleaseinputbookid:\n"); scanf("%s",id); while(p!=NULL) { if(strcmp(p->data.bookid,id)==0) break; else { q=p; p=p->next; } } if(p==NULL) printf("\nThebookyouwanttodeletearenotexit!\n"); else { q->next=p->next; free(p); printf("\nDeletesuccess!\n"); } printf("\nPressanykeyreturn....."); getchar(); getchar();}voidborrow(){ charid[5]; charmid[5]; linknodep; mlinknodeq; system("cls"); printf("borrowbook.....\n"); do { p=head->next; printf("Pleaseinputbookid:\n"); scanf("%s",id); while(p!=NULL) { if(strcmp(p->data.bookid,id)==0) break; else p=p->next; } if(p==NULL) { printf("\nThebookdoesn'texit!pleaseinputitagain!\n"); } }while(p!=NULL); if(p!=NULL) { do { q=mhead->next; printf("\nPleaseinputmemberid:\n"); scanf("%s",mid); while(q!=NULL) { if(strcmp(q->data.memberid,mid)==0) break; else q=q->next; } if(q==NULL) { printf("\nYouarenotmember!inputagain!\n"); } }while(q==NULL); if(q!=NULL&&(strcmp(p->data.bookmark,"Y"))!=0) { strcpy(p->data.bookmark,"Y"); strcpy(p->data.memberid,q->data.memberid); printf("\nsuccessed!\n"); getchar(); getchar(); } else { printf("\nThebookhaveborrowed,pleasewaitafewdays....."); getchar(); getchar(); } } printf("\nPressanykeyreturn....."); getchar(); getchar();}voidreturnbook(){ charid[5]; linknodep; system("cls"); p=head->next; printf("returnbook.....\n"); printf("Pleaseinputbookid:\n"); scanf("%s",id); while(p!=NULL) { if(strcmp(p->data.bookid,id)==0) break; else p=p->next; } if(p==NULL) printf("\nThebookyouwanttoretrunarenotexit!\n"); else { strcpy(p->data.bookmark,"N"); strcpy(p->data.memberid,"0"); printf("\nsuccessed!\n"); } printf("\nPressanykeyreturn....."); getchar(); getchar();}voidbookmanagetitle(){ system("cls"); printf("BOOKMANAGEMENU\n"); printf("*********************************************\n"); printf("*1:Lookallbooks*\n"); printf("*-------------------------------------------*\n"); printf("*2:Addbook*\n"); printf("*-------------------------------------------*\n"); printf("*3:Selectbookbyid*\n"); printf("*-------------------------------------------*\n"); printf("*4:Deletebookbyid*\n"); printf("*-------------------------------------------*\n"); printf("*5:Borrowbook*\n"); printf("*-------------------------------------------*\n"); printf("*6:Returnbook*\n"); printf("*-------------------------------------------*\n"); printf("*0:Returntomainform*\n"); printf("*********************************************\n"); printf("\nPleaseinputorder:\n");}voidbookmanage(){ intch; while(1) { bookmanagetitle(); scanf("%d",&ch); if(ch==0) break; switch(ch) { case1:printbookinfo(head); break; case2:addbook(); break; case3:select(); break; case4:deletebook(); break; case5:borrow(); break; case6:returnbook(); break; case0:break;default:printf("\nTouhaveinputthewrongorder!\n");printf("Pressanykeyreturn....."); getchar(); getchar(); } }}voidprintmemberinfo(mlinknodehead){ mlinknodemp=head->next; system("cls"); printf("Thememberinfomationsare....\n"); printf("%-7s%s\n","id","name"); printf("********************************************\n"); for(;mp!=NULL;mp=mp->next) printf("%-7s%s\n",mp->data.memberid,mp->data.membername); printf("\nPressanykeykeyreturn....."); getchar(); getchar();}voidaddmember(){ mlinknodep=(mlnode*)malloc(sizeof(mlnode)); system("cls"); printf("Addmember.....\n"); printf("%-7s%s\n","id","name"); printf("*******************************************\n"); scanf("%s%s",p->data.memberid,p->data.membername); p->next=mhead->next; mhead->next=p; printf("\nAddsuccess!"); printf("\nPressanykeyreturn....."); getchar(); getchar();}voidselectmember(){ charid[5]; mlinknodep; system("cls"); printf("selectmemberbyid.....\n"); p=mhead->next; printf("Pleaseinputmemberid:\n"); scanf("%s",id); while(p!=NULL) { if(strcmp(p->data.memberid,id)==0) break; else p=p->next; } if(p==NULL) printf("\nThemembernotexit!\n"); else { printf("\n%-7s%s\n","id","name"); printf("*****************************************\n"); printf("%-7s%s\n",p->data.memberid,p->data.membername); } printf("\nPressanykeyreturn....."); getchar(); getchar();}voiddeletemember(){ charid[5]; mlinknodep,q; system("cls"); printf("deletemember.....\n"); p=mhead->next; q=mhead; printf("Pleaseinputmemberid:\n"); scanf("%s",id); while(p!=NULL) { if(strcmp(p->data.memberid,id)==0) break; else { q=p; p=p->next; } } if(p==NULL) printf("\nThememberyouwanttodeletearenotexit!\n"); else { q->next=p->next; free(p); printf("\nDeletesuccess!\n"); } printf("\nPressanykeyreturn....."); getchar(); getchar();}voidmembermanagetitle(){ system("cls"); printf("MEMBERMANAGEMENU\n"); printf("*******************************************\n"); printf("*1:Lookallmemberinfo*\n"); printf("*-----------------------------------------*\n"); printf("*2:Addmember*\n"); printf("*-----------------------------------------*\n"); printf("*3:Selectmemberbyid*\n"); printf("*--------------------------------
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 第七单元21 古诗词三首山居秋暝说课稿-2024-2025学年五年级上册语文统编版
- 别墅保洁合同
- 北京市非居民其他垃圾清运合同
- 肝胆管癌外科治疗方案
- 旅游活动的分类依据
- 广东省茂名市信宜市2024-2025学年五年级上册期中考试语文试卷(无答案)
- 17 A光的折射 基础版2025新课改-高中物理-选修第1册(21讲)
- 河南省郑州市新密市2024-2025学年一年级(上)期中语文试卷(含答案)
- 激光比长仪相关行业投资规划报告范本
- 社交电商相关行业投资方案2
- 07版监理收费标准插入法计算器
- 重庆市七年级数学上学期期中试题新人教版
- 吉林省长春市东北师大附中2019-2020上学期——九年级数学大练习题试卷
- 废旧物的“新生命” 课件
- 污水处理厂关键部位施工监理控制要点
- 中医操作评分表
- 手工焊接作业指导书
- 拱桥悬链线计算表
- 半年分析----住院超过30天患者原因分析及改进措施
- 无公害农产品查询
- 研究生课程应用电化学(课堂PPT)
评论
0/150
提交评论