C语言程序设计报告-图书管理系统.doc

上传人:知****量 文档编号:13007161 上传时间:2022-04-27 格式:DOC 页数:35 大小:121KB
返回 下载 相关 举报
C语言程序设计报告-图书管理系统.doc_第1页
第1页 / 共35页
C语言程序设计报告-图书管理系统.doc_第2页
第2页 / 共35页
点击查看更多>>
资源描述

《C语言程序设计报告-图书管理系统.doc》由会员分享,可在线阅读,更多相关《C语言程序设计报告-图书管理系统.doc(35页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、- .航空航天大学金城学院?C语言程序设计?课程设计报告图书信息管理系统学号: XX:学号: XX:日期:目录一、需求分析:3二、程序的主要功能:.3三、程序运行平台:.3四、系统总框架图:.6五、程序类的说明: .6六、模块分析:.8七、比拟有特色的函数:.9八、存在的缺乏与编程体会10九、程序源代码:.10一、需求分析设计与分析一个图书信息管理系统,能够对图书的根据书名、价格或进展统计、处理和更新,并且可以方便学校教师和领导对图书进展整体分析。二、程序的主要功能 图书信息界面美观、简洁,采用菜单式显示功能选择; 能够从磁盘文件输入和输出数据; 能够对图书信息进展检索操作; 具有增、删、改信

2、息的功能; 使用构造体链表数据类型对图书信息进展描述和存储。三、程序运行平台VC6.0运行程序“library.exe,进入登录界面如下 * * 欢送光临 * * 图书信息管理系统 * =1-用户登录= =0-退出系统= 请输入您的选择:一、 输入1进展登录 - *图书信息管理系统* - * * | 1-添加图书 2-删除图书 | | 3-图书列表 4-图书排序 | | 5-查询图书 6-修改图书 | | 7-录入数据 0-退出系统 | * *请输入所选择的序号:选择1进入添加图书模块: 请输入您要添加的图书的编号:选择2进入删除图书信息模块: 请输入要删除的图书编号:选择3进入显示图书列表模

3、块图书信息列表如下 = 编号 图书名 作者名 类别 出版时间 价格 2 2 2 2 2 2 2.00 3 3 3 3 3 3 3.00 33 15 5 2 5 52 5.00 5 5 5 5 5 5 5.00 =:选择4.进入修改个人信息模块 1-按XX修改 请输入您的数字选择:选择5.进入图书排序模块 = * 1-按图书编号排序 2-按出版时间排序 * * 3-按图书价格排序 4-按图书名排序 * * 5-按作者名排序 0-取消排序操作 * =请输入您选择的编号:选择6.进入修改图书模块 *请输入要修改的图书编号:选择7.进入录入信息模块 注意:输入图书编码为0时完毕! 请输入图书编号: 选

4、择0.退出系统四、系统总框架图主函数写文件用户操作读文件添加信息删除信息查询信息修改信息五、程序类的说明struct bookint num;char bname50;char wname20;char press50;char sort50;int time;float price; struct book *next;/定义文件头指针;六、模块分析1. 添加模块系统将提示用户输入新添加的图书的信息,插入在链表中2. 删除模块首先由用户输入图书的编号,然后由删除模块判断p-num和用户输入的编号是否一样,一样那么从链表中删除。3. 图书列表模块传递一个头指针给print_book函数,假设头

5、指针不为空,那么将整个链表的数据输出。4. 图书排序模块首先由用户判断由什么关键词进展排序,然后运行相应的运行模块。5. 查询图书模块系统将会把所有航班的信息显示出来。由用户输入图书的编号,判断是p-num和用户输入的编号是否一样,一样那么输出。6. 修改图书模块 按照编号检索,然后修改相应的容。7. 录入模块 用while循环批量录入图书信息。0. 退出系统七、比拟有特色的函数void num_paixu(struct book *head)struct book *a1000,*p,*p1,*temp;int i,k,index,n=0;char b;p1=head;for(p=head;

6、p;p=p-next)n+;for(i=0;inext;for(k=0;kn-1;k+)index=k;for(i=k+1;inumnum)index=i; temp=aindex;aindex=ak;ak=temp; printf(排序成功!n);printf(是否显示排序结果?(y/n)n);scanf(%s,&b); getchar();switch(b)case n:break;case y: printf( =n); printf( * 编号 图书名 作者名 类别 出版时间 价格 *n); for(i=0;inum,ai-bname,ai-wname,ai-press,ai-sort

7、,ai-time,ai-price);printf( =n);break;default:printf(您的输入有误!n);break;八、存在的缺乏与对策、编程体会。排序的方式过于复杂,有待改良。九、参考文献百度文库十、程序源代码#include#include#includestruct bookint num;char bname50;char wname20;char press50;char sort50;int time;float price; struct book *next;/定义文件头指针;struct book *creatbook(); /创立链表struct boo

8、k *addbook(struct book *head); /添加图书int yanzheng(struct book *head,int m); /验证新添加的图书编码是否已存在void deletebook(struct book *head); /删除图书void fprint(struct book *head); /将链表写入文件struct book *load(); /从文件中读取信息并建成链表void print_book(struct book *head); /将链表信息输出void chaxun(struct book *head); /查询图书信息void num_c

9、haxun(struct book *head); /按图书编号查询图书void wname_chaxun(struct book *head); /按作者名查询图书void sort_chaxun(struct book *head); /按类别查询图书void time_chaxun(struct book *head); /按出版时间查询图书void bname_chaxun(struct book *head); /按图书名查询图书void xiugai(struct book *head); /修改图书信息void paixu(struct book *head); /对图书进展排序

10、void num_paixu(struct book *head); /按图书编号排序void time_paixu(struct book *head); /按图书出版时间排序void price_paixu(struct book *head); /按图书价格排序void bname_paixu(struct book *head); /按图书名排序void wname_paixu(struct book *head); /按作者名排序int main()int choice,n,x,y=1,c,c1=1234;char a,d,b10,b110=yjk;struct book *head

11、=NULL;while(y)system(cls); printf(nnnnnnn); printf( * 欢送光临 *nn); printf( * 图书信息管理系统 *nnn);printf(nn);printf( =1-用户登录=n);printf( =0-退出系统=n);printf( 请输入您的选择:);scanf(%d,&n);printf(n);getchar();switch(n)case 0:y=0;break;case 1: printf( 请输入您的用户名:); gets(b); printf(n); printf( 请输入您的密码:); scanf(%d,&c); pri

12、ntf(n); if(strcmp(b,b1)!=0|c!=c1) printf( 验证失败,请重新输入!n); scanf(%c,&d); getchar(); system(cls); else printf( 验证通过!请按Enter键进入!n); scanf(%c,&d); getchar(); x=1; while(x) system(cls); printf( -n); printf( *图书信息管理系统*n); printf( -nn); printf( *nn); printf( *nn); printf( | 1-添加图书 2-删除图书 |nn); printf( | 3-图

13、书列表 4-图书排序 |nn); printf( | 5-查询图书 6-修改图书 |nn); printf( | 7-录入数据 0-退出系统 |nn); printf( *nn); printf( *nn); printf(请输入所选择的序号:); scanf(%d,&choice); getchar(); system(cls); switch(choice) case 0: x=0;break; case 1: head=load(); if(head=NULL) printf(文件为空,请先录入数据!n); getchar(); break; else head=addbook(head

14、); printf(添加成功!n); printf(是否将新信息保存到文件?(y/n)n); scanf(%c,&a); getchar(); switch(a) case n: break; case y: fprint(head); printf(保存成功!n); getchar(); break; break; case 2: head=load(); if(head=NULL) printf(文件为空,请先录入数据!n); getchar(); break; else deletebook(head); getchar(); break; break; case 3: head=loa

15、d(); if(head=NULL) printf(文件为空,请先录入数据!n); getchar(); break; else print_book(head); getchar(); break; case 4: head=load(); if(head=NULL) printf(文件为空,请先录入数据!n); getchar(); break; else paixu(head); getchar(); break; case 5: head=load(); if(head=NULL) printf(文件为空,请先录入数据!n); getchar(); break; else chaxun

16、(head); getchar(); break; case 6: head=load(); if(head=NULL) printf(文件为空,请先录入数据!n); getchar(); break; else xiugai(head); getchar(); break; break; case 7: printf(注意:输入图书编码为0时完毕!n); head=creatbook(); printf(是否将输入的信息保存到文件以覆盖文件中已存在的信息?(y/n)n); getchar(); scanf(%c,&a); getchar(); switch(a) case n: break;

17、 case y: fprint(head); printf(保存成功!n); getchar(); break; break; default: printf(您的输入有误,请重新输入!n); getchar(); break;break;default:printf( 您的输入有误! 请重新输入!n);getchar();break;/录入数据并形成链表struct book *creatbook()struct book *head,*tail,*p;int num,time,n;char bname50,wname20,press50,sort50;float price;int siz

18、e=sizeof(struct book);head=tail=NULL;printf(请输入图书编号:);scanf(%d,&num); printf(请输入图书名:); scanf(%s,bname);getchar(); printf(请输入作者名:); scanf(%s,wname);getchar(); printf(请输入:); scanf(%s,press);getchar();printf(请输入类别:); scanf(%s,sort);getchar(); printf(请输入出版时间:); scanf(%d,&time);getchar(); printf(请输入价格:);

19、 scanf(%f,&price);getchar();while(1)p=(struct book *)malloc(size);p-num=num;strcpy(p-bname,bname);strcpy(p-wname,wname);strcpy(p-press,press);strcpy(p-sort,sort);p-time=time;p-price=price;p-next=NULL;if(head=NULL)head=p;elsetail-next=p;tail=p;do printf(请输入图书编号:); scanf(%d,&num);n=yanzheng(head,num);

20、if(n=0)break;elseprintf(您输入的编号已存在,请重新输入!n);while(1);if(num=0)break;else printf(请输入图书名:);scanf(%s,bname);getchar();printf(请输入作者名:);scanf(%s,wname);getchar();printf(请输入:);scanf(%s,press);getchar();printf(请输入类别:);scanf(%s,sort);getchar();printf(请输入出版时间:);scanf(%d,&time);getchar();printf(请输入价格:);scanf(%

21、f,&price);getchar();return head;/插入结点,并且插入后仍按一定顺序struct book *addbook(struct book *head)struct book *ptr,*p1,*p2,*p; char bname50,wname20,press50,sort50;int size=sizeof(struct book); int num,time,n=1;float price;do printf(请输入图书编号:); scanf(%d,&num);n=yanzheng(head,num);if(n=0)break;elseprintf(您输入的编号已

22、存在,请重新输入!n);while(1); printf(请输入图书名:); scanf(%s,bname);getchar(); printf(请输入作者名:); scanf(%s,wname);getchar(); printf(请输入:); scanf(%s,press);getchar();printf(请输入类别:); scanf(%s,sort);getchar(); printf(请输入出版时间:); scanf(%d,&time);getchar(); printf(请输入价格:); scanf(%f,&price);getchar();p=(struct book *)mal

23、loc(size); p-num=num; strcpy(p-bname,bname);strcpy(p-wname,wname);strcpy(p-press,press);strcpy(p-sort,sort);p-time=time;p-price=price;p2=head;ptr=p;while(ptr-nump2-num)&(p2-next!=NULL)p1=p2;p2=p2-next;if(ptr-numnum)if(head=p2)head=ptr;elsep1-next=ptr; p-next=p2;elsep2-next=ptr;p-next=NULL;return hea

24、d;/验证添加的图书编号是否已存在int yanzheng(struct book *head,int m)struct book *p;p=head;while(p!=NULL)if(p-num=m)break;p=p-next;if(p=NULL)return 0;elsereturn 1;/将新链表写入文件中void fprint(struct book *head)FILE *fp;char ch=1;struct book *p1;if(fp=fopen(f1.txt,w)=NULL)printf(File open error!n);exit(0);fputc(ch,fp);for

25、(p1=head;p1;p1=p1-next)fprintf(fp,%d %s %s %s %s %d %fn,p1-num,p1-bname,p1-wname,p1-press,p1-sort,p1-time,p1-price);fclose(fp);/从文件中读取图书信息struct book *load()FILE *fp;char ch;struct book *head,*tail,*p1;head=tail=NULL;if(fp=fopen(f1.txt,r)=NULL)printf(File open error!n);exit(0);ch=fgetc(fp);if(ch=1)

26、while(!feof(fp) p1=(struct book *)malloc(sizeof(struct book); fscanf(fp,%d%s%s%s%s%d%fn,&p1-num,p1-bname,p1-wname,p1-press,p1-sort,&p1-time,&p1-price); if(head=NULL) head=p1; else tail-next=p1; tail=p1; tail-next=NULL; fclose(fp); return head;elsereturn NULL;/将整个链表的信息输出void print_book(struct book *head)struct book *ptr;if(head=NULL)printf(n没有信息!n);return;printf( 图书信息列表如下n);printf( =n);printf( 编号 图书名 作者名 类别 出版时间 价格n);for(ptr=head;ptr;ptr=ptr-next)printf( %d %s %s %s %s %d %.2fn,ptr-num,ptr-bname,ptr-wname,ptr-press,ptr-sor

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 研究报告 > 设计方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com