计算机技术基础课程设计-图书馆管理系统C程序课程设计.doc_第1页
计算机技术基础课程设计-图书馆管理系统C程序课程设计.doc_第2页
计算机技术基础课程设计-图书馆管理系统C程序课程设计.doc_第3页
计算机技术基础课程设计-图书馆管理系统C程序课程设计.doc_第4页
计算机技术基础课程设计-图书馆管理系统C程序课程设计.doc_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

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

文档简介

湖南文理学院课程设计报告 课程名称: 计算机技术基础课程设计 系 部: 电 气 工 程 系 专业班级: 姓 名: 学 号: 指导教师: 完成时间: 2010年6月25日 报告成绩: 评阅意见: 评阅老师: 评阅时间:图书馆管理系统c程序课程设计一、设计目的通过本项课程设计,可以培养独立思考、 综合运用所学有关相应知识的能力,能更好的巩固c语言程序设计课程学习的内容,掌握 工程软件设计的基本方法,强化上机动手编程能力,闯过理论与实践相结合的难关!更加了解了c语言的好处和其可用性!同时增加了同学之间的团队合作精神!更加也体会到以后在工作中团队合作的重要性和必要性!通过c语言课程设计,使学生了解高级程序设计语言的结构,掌握基本的程序设计过程和技巧,掌握基本的分析问题和利用计算机求解问题的能力,具备初步的高级语言程序设计能力。为后续各门计算机课程的学习和毕业设计打下坚实基础二、设计要求在功能上功能尽量模拟windows操作系统中的图书馆管理体制,系统界面不做强制要求。 三、程序功能分析:图书馆管理系统是根据学校图书馆对书籍、员工、学生等方面管理与记录的需要。由c语言编写的一个多功能模块化的程序,其中包括图书检索(查阅图书)、借阅图书、还书及管理系统四项大的模块,其管理系统又包括图书管理系统、职员管理系统以及学生管理系统三大模块,分别对图书、管理人员、借书人员进行详细的记录与管理,包括图书的增加与删除、职员的增加与删除、借书卡的新加与删除,以及各项有关数据的统计,资料的修改和备份等功能。操作简单,查找方便,修改迅速,普遍适合图书馆的管理,可大大减少人工管理的工作量,提高工作效率。该软件将图书馆管理系统程序中的多中功能划分为多个模块,每个模块单独编辑,经过整合共同发挥功能。各函数多级调用,程序层次清晰,便于读取个修正。 有关本软件的具体功能分块可参考“图书馆管理系统数据结构图”(附录一)所示内容。四、定义数据结构及相关解释: (1)在图书馆管理系统中,各模块功能系统之间构成的数据结构关系为非线性数据结构的树结构。(2)树结构:每一个结点只有一个前件,称为父结点。没有前件的结点只有一个,称为树的根结点,简称树的根。在图书馆管理系统的数据结构图中“图书馆管理程序”为根;在树结构中,每一个结点都可以有多个后件,他们都称为该结点的子结点,没有后件的结点称为叶子。例如,在图书馆管理系统的数据结构土中“增加图书”、“删除图书”、“修改图书”、“书籍统计”为“图书管理系统”的子结点,也是该树结构的叶子。(3)图书馆管理系统树结构的度为4,深度为4。(4)详细可见“图书馆管理系统数据结构图”(附录一)。五、软件的模块划分:根据对图书馆管理系统功能分析的情况,现将图书馆管理系统源程序做如下模块划分:(1) main() 主函数 图书馆系统程序主函数;(2) chabook() 函数 查阅图书功能函数;(3) lendbook() 函数 借阅图书功能函数;(4) huanbook() 函数 还书系统功能函数;(5) addbook() 函数 增加图书功能函数;(6) delbook() 函数 删除图书功能函数;(7) changebook() 函数 修改图书资料功能函数;(8) bookcount() 函数 书籍统计功能函数;(9) addemploy() 函数 增加职员功能函数;(10) delemploy() 函数 删除职员功能函数;(11) changeemploy() 函数 修改员工资料功能函数;(12) employcount() 函数 员工统计功能函数;(13) addcar() 函数 申请新卡功能函数;(14) delcar() 函数 删除卡号功能函数;(15) lendcount() 函数 借书统计功能函数;(16) carcount() 函数 卡号统计功能函数;注:(2)(16)为自定义功能函数,通过main()主函数调用实现其功能。六、各功能模块编写内容详细情况及调试。(1)数据类型的定义。 在定义数据类型时,由于一项统计数据所需要的数据类型多样,如:职工统计时,编号、年龄为int型,名字、性别、级别为char型。所以在定义变量类型时采用结构体类型。如: struct student /*定义学生类型,用于存放借出的书籍*/ int carnum; char lendbook10; student1000; struct employ /*定义职工类型*/ int employnum; char employname15; int employage; char employsex2; char employleve10; long int employtage; employ50; struct book /*定义书的类型*/ int booknum; char bookname10; char bookcreat10; int turefalse; /*用于借书和还书模块判断一本书是否借出的条件*/ book1000; struct car /*借书卡的数据类型*/ int carnum; char studentname10; int studentclass; car100;(2)函数的命名和库函数的使用。 a.函数命名是遵循标识符的命名规则,并且要尽量做到顾名思义的效果。如:lendbook() 为图书借阅函数。 b.库函数使用时要提前声明(#include 等)用到的函数必须包括在库函数或者已自定义的函数中,否则编译出错。 c.函数调用时要注意形参和实参数据类型的对应。 (3)函数结构和功能实现。 a. 查阅图书函数“chabook()”b 借阅图书函数“lendbook()”c. 还书系统函数“huanbook()” 注: 以上的三个功能函数为图书馆管理系统的查阅、借书、还书等主要功能函数,其中主要运用字符串比较,定义指针变量,输入输出等多种函数和操作实现其对外界输入内容进行处理功能以及防止出错的备份功能。 d. 管理系统中的各个模块函数的功能实现基本都依靠与以上三中函数类似的编辑方法编写。主要通过以下结构实现对应功能。 for循环结构 对使用者输入内容与内部资料内容进行核对。 switch选择结构 对使用者所选择的项目进行判断并调用对应的函数。 if-else选择结构 配合for循环核对内容的正确与否选择对应的操作。 while 、do-while循环结构 条件判断并进行对应的操作。 e. 具体功能函数源程序的编辑内容见后文的图书馆管理系统源程序。 七、源程序内容及调试结果。 (1)源程序#include #include #include #include #include #define stack_init_size 10 #define ok 1 #define true 1 #define false 0 #define error 0 struct student /*定义学生类型,用于存放借出的书籍*/ int carnum; char lendbook10; student1000; struct employ /*定义职工类型*/ int employnum; char employname15; int employage; char employsex2; char employleve10; long int employtage; employ50; struct book /*定义书的类型*/ int booknum; char bookname10; char bookcreat10; int turefalse; /*用于借书和还书模块判断一本书是否借出的条件*/ book1000; struct car /*借书卡的数据类型*/ int carnum; char studentname10; int studentclass; car100; huanbook() /*还书函数*/ file *fp,*fp2; /*定义两个文件指针,fp2用于修改数据时设立临时文件用,防止数据遭破坏*/ int i,n; int carnum; char lendbook10; printf(write down your car number n); scanf(%d,&carnum); fp=fopen(car.txt,r); /*读取卡号记录*/ for(i=0;fread(&cari,sizeof(struct car),1,fp)!=0;i+) /*for循环判断卡号是否存在*/ if(cari.carnum=carnum) /*卡号存在,进入下一循环*/ n=i; fclose(fp); printf(write down the book name n); scanf(%s,lendbook); fp=fopen(record.txt,r); for(i=0;fread(&studenti,sizeof(struct student),1,fp)!=0;i+) /*判断是否借阅了输入的书*/ if(strcmp(studenti.lendbook,lendbook)=0) /*借阅了该书,进入下一循环,否则出错显示*/ fclose(fp); fp=fopen(record.txt,r); fp2=fopen(bookl.txt,w); for(i=0;fread(&studenti,sizeof(struct student),1,fp)!=0;i+) if(strcmp(studenti.lendbook,lendbook)=0) continue; /*删除还掉的书的借书记录*/ fwrite(&studenti,sizeof(struct student),1,fp2); /*写入原来没还的书的记录*/ fclose(fp); fclose(fp2); fp=fopen(record.txt,w); fp2=fopen(bookl.txt,r); for(i=0;fread(&studenti,sizeof(struct student),1,fp2)!=0;i+) fwrite(&studenti,sizeof(struct student),1,fp); /*将借书记录信息写回*/ fclose(fp); fclose(fp2); fopen(bookl.txt,w); /*清临时文件的记录*/ fclose(fp2); fp=fopen(book.txt,r); fp2=fopen(bookl.txt,w); for(i=0;fread(&booki,sizeof(struct book),1,fp)!=0;i+) /*将书的记录写入临时文件,防止因为修改信息破坏以前的记录*/ if(i=n) booki.turefalse=1; fwrite(&booki,sizeof(struct book),1,fp2); /*将还的书的原来状态设为无人借阅的*/ continue; fwrite(&booki,sizeof(struct book),1,fp2); fclose(fp); fclose(fp2); fp=fopen(book.txt,w); fp2=fopen(bookl.txt,r); for(i=0;fread(&booki,sizeof(struct book),1,fp2)!=0;i+) fwrite(&booki,sizeof(struct book),1,fp); /*将临时文件写回*/ fclose(fp); fclose(fp2); fopen(bookl.txt,w); /*清临时文件*/ fclose(fp2); printf(you have give the book back! press any key return !n); getch(); return; printf(you has never borrow this book! press any key return!n); /*出错提示*/ fclose(fp); getch(); return; printf(can not find his car! press any key teturn !n); /*出错提示*/ fclose(fp); getch(); lendcount() file *fp; int i,n=0; fp=fopen(record.txt,r); for(i=0;fread(&studenti,sizeof(struct student),1,fp)!=0;i+) printf(car number:%d name of the lent book:%s n,studenti.carnum,studenti.lendbook); n=n+1; fclose(fp); printf(now here are %d books has been lentn,n); printf(press any keyn); getch(); chabook() char ch5; do printf(-welcome to tushuguan!-n); printf( 1:n); printf( 2:n); printf( 0:n); printf(write 0-2,others error!n); scanf(%s,&ch5); switch(ch5) case 1:findbook();getch();break; case 2:printf(find by author n);getch();break; case 0:break; default:printf(error n);getch();break; while(ch5!=0); lendbook() file *fp,*fp2; int i,n; int carnum; printf(write down your car number :n); scanf(%d,&carnum); fp=fopen(car.txt,r); for(i=0;fread(&cari,sizeof(struct car),1,fp)!=0;i+) if(cari.carnum=carnum) n=i; fclose(fp); printf(write down the book name n); scanf(%s,studentn.lendbook); fp=fopen(book.txt,r); for(i=0;fread(&booki,sizeof(struct book),1,fp)!=0;i+) if(strcmp(booki.bookname,studentn.lendbook)=0) if(booki.turefalse=0) printf(sorry this book has bean lent outn);fclose(fp);getch();return; else fclose(fp); fp=fopen(record.txt,a+); studentn.carnum=carnum; fwrite(&studentn,sizeof(struct student),1,fp); fclose(fp); fp=fopen(book.txt,r); fp2=fopen(bookl.txt,w); for(i=0;fread(&booki,sizeof(struct book),1,fp)!=0;i+) if(strcmp(booki.bookname,studentn.lendbook)=0) booki.turefalse=0; fwrite(&booki,sizeof(struct book),1,fp2); continue; fwrite(&booki,sizeof(struct book),1,fp2); fclose(fp); fclose(fp2); fp=fopen(book.txt,w); fp2=fopen(bookl.txt,r); for(i=0;fread(&booki,sizeof(struct book),1,fp2)!=0;i+) fwrite(&booki,sizeof(struct book),1,fp); fclose(fp); fclose(fp2); fopen(bookl.txt,w); fclose(fp2); printf(successed press any key return!n); getch(); return; printf(cannot find this book n); fclose(fp); getch(); return; printf(cannot find your car number !n); fclose(fp); getch(); carcount() file *fp; int i,n=0; fp=fopen(car.txt,r); for(i=0;fread(&cari,sizeof(struct car),1,fp)!=0;i+) printf(number %dn,i+1,cari.carnum,cari.studentname,cari.studentclass); n=n+1; fclose(fp); printf(now here are %d books!n,n); printf(press any key!n); getch(); delcar() file *fp,*fp2; int i; int carnum; char choice; fp=fopen(car.txt,r); fp2=fopen(bookl.txt,w); printf(write the number of the car that to delete!n); printf(this car number will be deleted or there has that number first!n); scanf(%d,&carnum); for(i=0;fread(&cari,sizeof(struct car),1,fp)!=0;i+) if(cari.carnum!=carnum) fwrite(&cari,sizeof(struct car),1,fp2); fclose(fp); fclose(fp2); printf(are you sure to delete this car?y/nn); scanf(%s,&choice); if(choice=y|choice=y) fp=fopen(car.txt,w); fp2=fopen(bookl.txt,r); for(i=0;fread(&cari,sizeof(struct car),1,fp2)!=0;i+) fwrite(&cari,sizeof(struct car),1,fp); fclose(fp); fclose(fp2); fp2=fopen(bookl.txt,w); fclose(fp2); printf(press any key to returnn); getch(); return; else printf(press any key to return n); getch(); return; addcar() file *fp; int i=0; fp=fopen(car.txt,a+); printf(write down your car number n); scanf(%d,&cari.carnum); printf(write your name n); scanf(%s,cari.studentname); printf(write your class number n); scanf(%d,&cari.studentclass); fwrite(&cari,sizeof(struct car),1,fp); fclose(fp); printf(load successed! press any key to return n); getch(); changemploy() file *fp,*fp2; char employname10,choice; int i; fp=fopen(employ.txt,r); fp2=fopen(bookl.txt,w); printf(write the name to change n); scanf(%s,employname); for(i=0;fread(&employi,sizeof(struct employ),1,fp)!=0;i+) if(strcmp(employi.employname,employname)=0) printf(please write what you want to change n); printf(n,employi.employnum,employi.employname,employi.employage,employi.employsex,employi.employleve,employi.employtage); printf(1:employee numbern); printf(2:employee namen); printf(3:employee agen); printf(4:employee payn); printf(5:employee degreenn); printf(please write 1-5:); scanf(%s,&choice); switch(choice) case 1: printf(write the new employee number n); scanf(%d,&employi.employnum); fwrite(&employi,sizeof(struct employ),1,fp2); break; case 2: printf(write the new employee name n); scanf(%s,employi.employname); fwrite(&employi,sizeof(struct employ),1,fp2); break; case 3: printf(write the new age n); scanf(%d,&employi.employage); fwrite(&employi,sizeof(struct employ),1,fp2); break; case 4: printf(write the new pay n); scanf(%d,&employi.employtage); fwrite(&employi,sizeof(struct employ),1,fp2); break; case 5: printf(write the new degreenn); scanf(%s,employi.employleve); fwrite(&employi,sizeof(struct employ),1,fp2); defaut:printf(error!);break; continue; fwrite(&employi,sizeof(struct employ),1,fp2); fclose(fp); fclose(fp2); fp=fopen(employ.txt,w); fp2=fopen(bookl.txt,r); for(i=0;fread(&employi,sizeof(struct employ),1,fp2)!=0;i+) fwrite(&employi,sizeof(struct employ),1,fp); fclose(fp); fclose(fp2); fp2=fopen(bookl.txt,w); fclose(fp2); printf(press any key to return n); getchar(); return; delemploy() file *fp,*fp2; int i; char employname10,choice; fp=fopen(employ.txt,r); fp2=fopen(bookl.txt,w); printf(write the name to deleten); printf(the name has been changed or there has not the name first n); scanf(%s,employname); for(i=0;fread(&employi,sizeof(struct employ),1,fp)!=0;i+) if(strcmp(employname,employi.employname)!=0) fwrite(&employi,sizeof(struct employ),1,fp2); fclose(fp); fclose(fp2); printf(are you sure to delete ?y/nn); scanf(%s,&choice); if(choice=y|choice=y) fp=fopen(employ.txt,w); fp2=fopen(bookl.txt,r); for(i=0;fread(&employi,sizeof(struct employ),1,fp2)!=0;i+) fwrite(&employi,sizeof(struct employ),1,fp); fclose(fp); fclose(fp2); fp2=fopen(bookl.txt,w); fclose(fp2); printf(press any key to return n); getch(); return; else printf(press any key to return n); getch(); return; employcount() file *fp; int i,n=0; fp=fopen(employ.txt,r); for(i=0;fread(&employi,sizeof(struct employ),1,fp)!=0;i+) printf(number %d the message is :nn,n+1,employi.employnum,employi.employname,employi.employage,employi.employsex,employi.employleve,employi.employtage); n+; fclose(fp); printf(there are %d employeesn,n); printf(press any key to return ); addemploy() file *fp; char choice=y; int i=1; fp=fopen(employ.txt,a+); while(choice=y|choice=y) printf(please write the employee numbern); scanf(%d,&employi.employnum); printf(please write the employee namen); scanf(%s,employi.employname); printf(please write the employee agen); scanf(%d,&employi.employage); printf(please write the employee sexn); scanf(%s,employi.employsex); printf(please write the employee degreenn); scanf(%s,employi.employleve); printf(please write the employee payn); scanf(%d,&employi.employtage); fwrite(&employi,sizeof(struct employ),1,fp); printf(do you want to write next?n); scanf(%s,&choice); printf(press any key to return n); fclose(fp); addbook() file *fp; int i=0; char choice=y; fp=fopen(book.txt,a+); while(choice=y|choice=y) printf(write the no.%d numbern,i+1); scanf(%d,&booki.booknum); printf(please write the book namen); scanf(%s,booki.bookname); printf(please write the book name authorn); scanf(%s,booki.bookcreat); printf(press 1 or 0 1-yes 0-non); printf(please write the book zhuangtain); scanf(%d,&booki.turefalse); fwrite(&booki,sizeof(struct book),1,fp); printf(do you want to write the next one?n); scanf(%s,&choice); fclose(fp); bookcount() file *fp; int i,n=0; fp=fopen(book.txt,r); for(i=0;fread(&booki,sizeof(struct book),1,fp)!=0;i+) if(booki.booknum!=0&strlen(booki.bookname)!=0&strlen(booki.bookcreat)!=0) printf(the no.%d bookn,i+1,booki.booknum,booki.bookname,booki.bookcreat,booki.turefalse); n=n+1; fclose(fp); printf(now there have %d booksn,n); printf(press any key to return n); findbook() file *fp; char bookname10; int ture,i; fp=fopen(book.txt,r); printf(write the book name n); scanf(%s,bookname); for(i=0;fread(&booki,sizeof(struct book),1,fp)!=0;i+) if(strcmp(bookname,booki.bookname)=0) if(booki.turefalse=1) printf(the messageof this book is:%d %s %s this book has not been lend n,booki.booknum,booki.bookname,booki.bookcreat); else printf(this book has been lent n);fclose(fp);return; fclose(fp); return; printf(there has not this book n); fclose(fp); return; delbook() file *fp,*fp2; int i; char bookname10,choice; fp=fopen(book.txt,r); fp2=fopen(bookl.txt,w); printf(please write the book namen); printf(the book has been deleted or there has not that name n); scanf(%s,bookname); for(i=0;fread(&booki,sizeof(struct book),1,fp)!=0;i+) if(strcmp(bookname,booki.bookname)!=0) fwrite(&booki,sizeof(struct book),1,fp2); fclose(fp); fclose(fp2); printf(are you sure to delete this book?y/nn); scanf(%s,&choice); if(choice=y|choice=y) fp=fopen(book.txt,w); fp2=fopen(bookl.txt,r); for(i=0;fread(&booki,sizeof(struct book),1,fp2)!=0;i+) fwrite(&booki,sizeof(struct book),1,fp); fclose(fp); fclose(fp2); fp2=fopen(bookl.txt,w); fclose(fp2); printf(press any key to return n); getch(); return; else printf(press any key to return n); getch(); return; changebook() file *fp,*fp2; char bookname10,choice; int i; fp=fopen(book.txt,r); fp2=fopen(bookl.txt,w); printf(please write the book name n); scanf(%s,bookname); for(i=0;fread(&booki,sizeof(struct book),1,fp)!=0;i+) if(strcmp(booki.bookname,bookname)=0) printf(你所要修改的书的资料如下,请

温馨提示

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

评论

0/150

提交评论