大一c语言课程设计图书信息管理系统_第1页
大一c语言课程设计图书信息管理系统_第2页
大一c语言课程设计图书信息管理系统_第3页
大一c语言课程设计图书信息管理系统_第4页
大一c语言课程设计图书信息管理系统_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、壽级语言程序役计vh学 院班 级姓 名学 号成 绩指导老师一、目的1、进一步掌握和利用c语言进行程设计的能力;2、进一步理解和运用结构化程设计的思想和方法;3、初步掌握开发一个小型实用系统的基本方法;4、学会调试一个较长程序的基本方法;5、学会利用流程图或ns图表示算法;6、掌握书写程设计开发文档的能力(书写课程设计报告);二、内容与设计思想。(1)题目:图书信息包括:登录号、书名、作者名、分类号、出版单位、出版时间、价格等。 试设计一图书信息管理系统,使之能提供以下功能:系统以菜单方式工作图书信息录入功能(图书信息用文件保存)一一输入图书信息浏览功能一一输出查询和排序功能:(至少一种查询方式

2、)一一算法按书名查询按作者名查询图书信息的删除与修改(可选项)(2)系统功能与分析(填写你所设计的菜单及流程图)截图略 流程图:按书名查找模块流程图按作者查找模块流程图插入模块流程图(3)数据结构 typedef struct book int sort;char book_name15;char author_name15;int vert_number;char publish_unit15;char publish_time10;int price;b(4) 模块设计根据功能需要:源文件函数名功能save ()保存input ()输入get ()获取output ()输出book nam

3、e通过书名查找aut hor ncime ()通过作者查找modify ()修改delet ()删除(5)总体设计思想:1 图书信息管理系|(6) 调试过程:测试数据及结果,出现了哪些问题截图略(7) 程序有待改进的地方及本次实习的收获和建议(8) 源程序清单(主要代码)#include<stdio.h>#include<stdlib.h> #include<string<h>#define len sizeof(struct book)typedef struct bookint sort;char book_name15;char author_n

4、ame 15; int vert_number;char publish_unit15;char publish_time 10; int price;b;b *p,*pl,boo;int num=0,f=0;int save();void input();int get();void output();void book_name();void author_name();void modifyo;void delet();int main()int re=l,tj=o;int n,choice;while(re=l)t=l;system(mclsm);printf(h2% 11 rjw 咛

5、 rjwrjwrjwrjwrjwrjwrjw ejw rjw卜卜rjwrjw%|printf(h主菜单nnh);printf(n1 录入信息n”);printf(n2 査看信息n”);printfc*3 查询信息n”);printf(n4 删除与修改信息>t);printf(m5 退出 n“);printf(h%!* *!*” f # *2“和心“卡杠“);printf(nnh);if(j=l) printf(mnt 选择错误!”);printf(nnt 请选择 1-5: _bbn);scanf(h%dh,&choice);switch(choice)/icase 1:print

6、f(nntl:录入信息n”); input();printf(un tl返回主菜单;nt 2退出 ntt 请选择:_bb”); scanf(h%dn,&re);break;case 2:printf(nnt2.查看信息 n”);output();printf(unt 1返回主菜单;nt2退出ntt 请选择:_bb");scanf(n %d*&re);break;case 3:while(t=l)printf(mnt3.查询信息 n”); printf(mnt请选择查询方式:nt1按书名nt2按作者名nt3 其余任意数字键返回主菜单_bb“);scanf(n%d'

7、;*,&n);if(n=l)book_name();else if(n=2) author_name();elsere=l;goto lebel;pnntf(hnt1返回上一层;nt2返回主菜单;nt 3退出ntscanf(m%dh,&t);if(t=l)system(f,clsh);if(t=2)re=l;if(t=3) re=o;lebel: break;case 4:while(t=l|f=l)t 3.3 退出printf(nnt4.删除与修改信息n”); printf(hnt请选择:nt1 删除信息;nt2 修改信息n其余任意数字键返回主菜单_bb”);scanf(n%

8、d'*,&n);if(n=l)delet();else if(n=2)modifyo;elsere=l; goto lebe;printf(*'nt 1返回上一层;nt2返回主菜单;ntntt请选择:_bbh);scanf(,%dh,&t);if(t=l)system(hclsn);if(t=2) re=l;if(t=3) re=0;lebe: break;case 5:re=0;break;default:re=l;j=l;return 0;int save()file *fp;int i,n=0,nl=0;if(fp=fopen(nbook.txtm,ma+

9、m)=null)return 0;fprintf(fp,m %dnm,num);for(i=0;i<num;i+)fprintf(fp,n%d %s %s %d %s %s %d",pi.sort,pi.book_name,pi.author_name,pi.vert_number,pi.publish_unit,pi.publish_time,pi.price);fprintf(fp,mnn);fclose(fp);return 1;int get()file *fp;int i;fp=fopen(hbook.txth,hrh);if(fp=null)return 0;els

10、efscanf(fp9h %d"9&num);if(num>0)p=(b *)malloc(len * num);for(i=0;i<num;i+)fscanf(fp,m%d%s%s%d%s%s%dm,&pi.sort9pi.book_name9pi.author_name&pi>vert_number,pi>publish_unit,pi<pubiish_time,&pi.price);fclose(fp);return 1;elsefclose(fp);return 0;void input()int result;i

11、nt i;printf(ntt要录入信息的书籍数量为:本bb”);scanf(m%dm,&num);if(num>0)p=(b *)malloc(len * num);for(i=0;i<num;i+)pi.sort=i+1;printf(hntno. %dn,pi.sort);printfcwj;printtvat请按序输入:书名 作者名 分类号 出版单位 出版时间 价格nttm);scanf(m%s%s%d%s%s%dn,plij.book_nanie,pij.author_name, dplilvertnumbedpiipublish_unit,pi.publish_

12、time,&pi.price);printf(nnm);result=save();if(result=0)printf(h num = 0;t录入信息失败!n”);if(result=l)printf(ht成功录入信息!nh);elsenum=o;printf(ht 输入错误!");void output()int i;get();if(get()=l)printf(nntt 成功获取信息!nn);for(i=0;i<num;i+) printf(hnttno.t%dnm,pi.sort);printf(ntt 书名作者名 序列号 出版单位出版时间 价格%dfpije

13、book_name,pij<author“);printf(ntt %s %s %d %s %s_name,pi.vert_number,pi.publish_unit, pi.publish_time,pi.price);printf(hnh);else printf(mt文件打开错误!”);void book_name()int i;int tag=o;char ch15;printf(ht请输入书名:_bb”);scanf(h%sfch);if(get()=o)printf(ht 无法査询! ”);return;if(get()=l)for(i=0;i<nuni;i+)if(

14、strcmp(pi.book_name,ch)=0)printir*ntt排列号 书名 作者名 序列号出版单位 岀版时间价格十);printf(ntt %d %s %s %d %s %s %dnn,pi.sort,pi.book_n ame,pi.author_name9pi.vert_number9pi.publish_unit9pi«publish_time9pi.price);tag=l;if (tag = 0)printf(mii t 没有相关信息!nm);void author_name()int i;int tag=0;char ch15;printf(ht请输入作者名:

15、_bbh);scanf(h%sm,ch);if(get()=o)printf(mt 无法查询!");return;if(get()=l)for(i=0;i<num;i+)if(strcmp(pi.author_namech)=0)printf("ntt排列号书名 作者名序列号出版单位出版时 间价格w');printf(htt %d %s %s %d %s %s %dnn,pi.sort,pi.book_name,pi.author_name9pi.vert_number9pi.publish_unit,pi.publish_time9pi.price);tag

16、=l;if (tag = 0)print" t没有相关信息!”);void modifyoint t,n,i,y=l;int result,z,x;t=get();if(t=o)printf("n t打开文件错误,无法修改!”);return;else if(y=l)printf(mnt您要修改信息的图书排列号为(l-%d): _bbh,num);scanf(n%dh,&n);if(n>=l&&n<=num)foi'(i=0;ivnum;i+)if(pi.sort=n)printf(hnt您即将修改以下信息:nh);printfv

17、tt排列号书名 作者名 序列号出版单位岀版时间 价 格n”);printf(mtt %d %s %s %d %s %s %dn,pij.sort,pij.book_name,pi.author_name,pi.vert_number,pi.publish_unit,pi.publish_time9pi.price);printf(mnnt确认请按1;返回请按2;返回上一层请按3_bbn);scanf(h%dm,&x);if(x=l)/pl=&boo;printf(ht您要将信息修改为:nm);printf(mtt 书名:_bb”);scanf(n %sh,pi.book_nam

18、e);printf(htt 作者名:_bbm);scanfc* %s”, pi.author_name);printf(htt 序列号:_bb“);scanf(n%dn,&pi.vert_number);printf(mtt 出版单位:_bbh);scanf(h%s*,pi.publish_unit);printf(ntt 出版时间:_bbh);scanf(n %sh,pi.publish_time);printf(mtt 价格:_bbm);scanf(n %dm,&pi.price);strcpy(pi.book_name,pi.book_name); strcpy(pi.a

19、uthor_nanie,pi+l.author_name); pij.vert_number=pi+l.vert_number; strcpy(pi.publish_unit,pi+l.publish_unit); strcpy(pi.publish_time,pi+l.publish_time);pi.price=pi+l .price;y=o;z=l;elseif(x=2)y=l;z=o;elseelseprintf(ht输入错误,请重新输入:”);y=i; vvhile(z=l)result=save();if(result=o)printf(unt修改信息失败!nm);z=0;if(result=l)printf(miit 成功修改信息!1t);z=0;return;void delet()intint result,z=0,x;t=get();if(t=o)printf(mnt打开文件错误,无法删除!”);return;elsevvhile(y=l)printf(nnt您要删除信息的图书排列号为(l-%d): _bbh,num);scanf(n%dm,&n);if(n>=l&&n<=num)for(i=0;i<num;i+)if(pi.sort=n)printf(unt您即将删除以下信息:nm);价格

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论