图书管理系统 (c语言)
C语言程序课程设计图书管理系统方案

C语言程序课程设计报告标题:图书管理系统专业:软件工程类:设计主题图书馆管理系统主要包括管理图书的库存信息,每本书的借阅信息,每个人的借阅信息。
每本书的库存信息包括数量、书名、作者、出版日期、金额、类别、总入库数量、当前库存、已借出图书数量等。
每本借书包括以下信息:编号、书名、金额、借书证号、借阅日期、到期日期、罚款金额等。
每个人的图书馆信息包括借书证号、班级、学号等。
该系统的功能包括以下几个方面:一、借阅资料管理要求对图书、期刊、报纸、期刊进行分类管理,这样操作会更加灵活方便。
可以随时添加、删除、修改、查询等相关资料。
b、借贷管理(1)借贷操作(2)还书操作(3)更新治疗提示:以上处理需要相互配合,通过编辑赔偿和违约金金额来完成图书借还业务的各种登记。
例如,读者在还书时,不仅要更新图书的库存信息,还要自动计算图书的罚款金额。
并显示读者当天到期未还图书的所有信息。
c、读者管理读者等级:对借阅的读者进行分类,比如可以分为教师和学生两类。
并定义每类读者可以借阅的图书数量及相关借阅时间等信息。
读者管理:可以录入读者信息,以及挂失或注销读者、查询等服务。
D.统计分析可以随时进行统计分析,及时了解当前的借阅情况和相关数据状态。
统计分析包括借阅列表、数据状态统计、借阅统计等功能分析,显示当日所有到期未还的图书信息。
e系统参数设置:您可以设置相关的系统服务器参数,如违约金金额、最大借用天数等。
根据题目分析这项工作分为六个模块。
1.图书数据2.借款人信息3.借用模块4.还书模块5.照看书籍6.查询模块模块一:书号,书名,作者,出版时间,价格,份数,页数。
模块二:单位、借阅书目、借阅时间模块3:输入书名、书号、借书证。
模块四:登记书号,还书,处理罚款。
模块5:管理书库中的书籍,将新书入库,删除旧书,堆栈查询模块6:图书查询。
数据测试源代码汉字菜单可以参照以下代码编写:#包含“stdio.h”。
主(){ char c;int I;做{clr SCR();for(I = 0;i < 80i++)printf(" * ");printf("\t 1:添加书籍\ n ");printf("\t 2:列出书籍\ n ");printf(" \ t 3:s reach books \ n ");printf("\t 4:借书\ n ");printf("\t 5:返回图书\ n ");printf("\t6:退出\n ")printf(" \ t请选择输入选项[1 \ \ 2 \ \ 3 \ \ 4 \ \ 5 \ \ 6]:\ n ");做{c = getchar();}while(c!='1'&&c!='2'&&c!='3'&&c!='4'&&c!='5'&&!='6');getchar();开关(c){事例“1”:输入();打破;案例“2”:del();打破;事例“3”:find();打破;case“4”:arrange();打破;事例“5”:right();打破;案例“6”:出口(0);}Printf("按任意键返回主菜单:\ n ");getchar();clr SCR();} while(1);}#include <stdio.h >定义图书结构*/结构书{int _ id#include <stdlib.h >#include <string.h >#定义借入1#定义NOBORROW 0/*//数字,唯一char _ name[32];//书的名称,不唯一int _ type//书的类型,不唯一int _ status//书的状态,借出/未借出int _ count//图书借出的次数struct Book * _ next//下一本书结构书* _ prev//前一本书};定义书籍类型*/操作目录提示*/操作目录提示1 */添加图书类型并显示用户信息*/添加图书状态并显示用户信息。
C语言课程设计图书馆管理系统程序代码

#include〈stdio.h〉#include<windows.h〉#include〈string。
h〉#include<conio。
h>#define M 100struct books{char tsmc[12];inttsbh;float dj;char zz[12];char czzt[12];char xm[12];char xb[12];intxh; }s[M];int N;bool flag;intmain (){intsele;flag=0;sele=1;void sr();void cx();void sc();void js();void hs();void tc();void jsh();//system ("tsgl”);printf("\n\n");printf(" ************************\n"); printf(" 1:输入2:查询3:删除\n");printf(”4:借书5:还书0:退出\n");printf(” ************************\n"); while(1){printf(”\n\n请输入功能序号:");scanf (”%d",&sele);if(sele>=0 && sele<=5){switch(sele){case 1:sr();break;case 2:cx();break;case 3:sc();break;case 4:js();break;case 5:hs();break;case 0:jsh();break;}if(flag)break;printf(”\n\n");printf(” ************************\n”); printf(" 1:输入2:查询3:删除\n");printf(”4:借书5:还书0:退出\n”);printf(” ************************\n”);}else{printf(”输入错误请再次输入|\n\n");printf("\n\n");printf(” ************************\n”);printf(" 1:输入2:查询3:删除\n”);printf(”4:借书5:还书0:退出\n");printf(" ************************\n");}printf("\n\n让任意键继续\n”);} //wr_file();}/******主函数***//*********输入*********/void sr(){intn,i;N=0;printf("可输入的书本数:");scanf("%d",&n);N=n+N;printf("请输入相关信息:\n");for(i=1;i<=n;i++){printf(”图书名称:”);scanf(”%s",s[N-n-1+i]。
C语言图书管理系统实验报告

程序设计实践信息类 1110开辟一个图书信息管理系统,图书信息包括:图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据自己情况进行扩充,比如是否借出、库存量等)(1)图书信息录入功能(图书信息用文件保存)--输入(2)图书信息浏览功能--输出(3)查询功能(至少一种查询方式)、排序功能(至少一种排序方式):①按书名查询②按作者名查询③ 按照价钱排序④按出版时间排序等等(4)图书信息的删除与修改(1)简单的权限处理 (2)报表打印功能(3)甚至根据自己情况,可以加之学生信息,并扩充为图书借阅系统。
(4) 含糊查询 (5)综合查询 (6)统计功能比如统计处某一类别的图书信息或者筛选出小于指定数量库存的图书信息等等,总之,可以根据自己需求进行分析功能。
一、提交材料应包括: (1)系统源代码 (2)课程报告二、整个设计过程具体要求(1要求学生对案例系统进行分析,设计出需要完成的功能,完善各个模块的调用关系;(2要求学生进一步明确各模块调用关系,进一步完善模块函数细节(函数名、参数、返回值等)(3要求学生养成良好的编码习惯、完成各个模块并进行测试,最终完成系统整体测试;(4按照要求完成系统设计和实现报告,并进行总结、答辩。
1 需求分析这是一个能简单管理图书的小型图书管理系统,其中图书信息包括:书名,作者名,书编号,分类,出版单位,出版时间,价格等。
通过这些信息使之提供以下功能:(1)图书信息创建功能。
其中图书信息包括:书名,作者名,书编号,分类,出版单位,出版时间,价格等。
(图书信息用文件保存)。
(2)图书信息查看功能。
用来查看各项图书信息。
(3)图书信息查找功能。
通过已知信息来查找想要的图书。
(4)图书信息的删除。
可以删除特定图书。
(5)图书信息的修改。
可以修改图书的各项信息。
(6)图书信息的排序功能。
按图书信息对录入的图书进行排序。
(7)菜单选择功能,此功能也是图书信息信息管理系统的入口,用户所要进行的各种操作均需在此模块中进行选择并进而调用其他模块实现相应的功能2 概要设计图书管理系统中主要的数据结构包含书名、图书书号、作者名、分类、出版社、出版时间、价格等;在处理过程中各项可以作为一本图书的不同属性来进行处理。
图书馆管理系统C语言程序设计

HUNAN UNIVERSITY C语言程序训练报告【设计目的】图书信息包括:读者登录号、管理员登录号、图书编号、作者名、种类、出版社、图书库存、图书借出数目等。
图书信息管理系统,使之能提供以下功能:1)系统以菜单方式工作2)读者注册功能3)读者登录功能4)读者借书还书功能5)查询读者借阅记录6)查询在管图书信息功能7)修改密码功能8)管理员登录功能9)增加、修改、删除图书功能10)查看图书信息功能【设计思路】根据题目要求,应当把图书信息用结构体形式输入,应该提供以下结构体和文件的输入等操作:在程序中需要实现图书信息录入,浏览,查询,删除和修改等功能的操作,所以需要建立相应的模块来实现:另外还需提供选择菜单实现功能,在运行时达到所要求的目的;管理员和读者登录界面及各自功能应有不同的实现。
【总体设计】【详细设计】1.主函数主函数设计要求简洁,只提供部分提示语和函数的调用源代码为//rkou。
c 程序的入口#include<stdio。
h>#include〈stdlib.h〉#include〈string。
h>#include<conio.h〉#include"head.h”#include”fuc.h"#include”picture。
h"#include”jiangzhuo1.h"#include”output。
h"main(){ int i=setup();switch (i){ case 0: while(n<50){ conects(n);}default:eros(i);}system("pause”);}2.程序中全局变量声明定义,以及所有函数声明源代码为struct book //图书结构体声明{ char name[50],classic[10],writer[20]; //书名,类别,作者int jn; //借出数量int zn; //在馆数量int bh; //图书编号};struct information //管理员和读者结构体声明{char name[10],no[12],key[10]; //姓名,账号,密码};struct show //图书借阅记录的结构体声明{char name1[10],name2[50],writer[20],no[12]; //书名,读者姓名,书的作者,读者账号int bh,o; //图书编号,借阅状况(未还,已还)};//以下为用到的全局变量struct book bk;struct information aa,rr;struct information stu[100];struct book bb[100];struct information ad[100];struct show ss[100];int i,j,k,s;int n=0;int x;FILE *fp;//以下函数主要功能:方便窗口与用户之间交换信息int regst();void password(char *a,int b,int j);//登陆时的输入函数void examine(int *a,int b); //保证键入的数据是数字void changepaw(int a,int b); //修改密码用到的提示函数void inputs0(); //输出图书类别以供用户选择void inputs1(int a,int b,int c,int d,int e); //方便用户输入图书各项信息(如书名,编号)void inputs2(int a,int b,int c); //方便用户输入管理员的信息(如账号姓名)void inputs3(int a,int b,int c);//方便用户输入读者的信息(如账号姓名)void eros(int i); //错误显示函数,操作一旦出错,则会出现相应的错误信息void conects(int j); //连接函数,选择界面//一下函数主要用于改变文件的内容并保存int setup(); //数据初始化函数int xzc(char no[12],char key1[10],char key2[10],char name[10]);//读者注册函数int exam(char no[10],char key[10],int n);//密码账号检验函数int mp(char no[12],char key1[10],char key2[10],char key3[10],int n); //密码修改函数void paixu(); //对图书按照编号从小到大的顺序进行排列int sc(int bh); //管理员删除图书信息函数int zj(struct book bb); //管理员增加图书信息函数int xg(struct book bb);//管理员修改图书信息函数int js(int bh,char no[12]); //借书函数int hs(int bh,char no[12]); //还书函数int bh1(int bh); //判断该编号的图书信息是否存在函数void bh2(int bh); //按照图书编号显示图书信息函数int sm1(char name[50]);//判断是否存在该名字的图书信息函数void sm2(char name[50]); //按照图书名字显示图书信息函数int zz1(char writer[20]); //判断是否存在该作者的图书信息函数void zz2(char writer[20]);//按照图书作者显示图书信息函数void lb(char classic[10]); //按类别显示图书信息int rck1(int bh);//判断该编号的图书的借书记录是否存在void rck2(int bh);//按编号显示图书借书情况int gck21(char no[12]);//判断该账号读者的借书记录是否存在void gck22(char no[12]); //按读者显示借书情况2void gck12(); //显示全部借书情况void gck23();//管理员查看所有书的信息void copy(int bh); // 按编图书编号将图书信息暂时保存在另外一个结构体里面void copy2(char no[12]); //按管理员账号将管理员信息暂时保存在另外一个结构体里面void copy3(char no[12]);//按读者账号将读者信息暂时保存在另外一个结构体里面//pic()函数:每个函数表示一个界面,conects函数将它们连接起来void pic0();void pic1();void pic2();void pic3();void pic4();void pic5();void pic6();void pic7();void pic8();void pic9();void pic10();void pic11();void pic12();void pic13();void pic14();void pic15();void pic16();void pic17();void pic18();void pic19();void pic20();void pic21();void pic22();void pic23();void pic24();void pic25();void pic26();void pic27();void pic29();void pic30();void pic31();void pic32();void pic33();void pic34();void pic35();void pic36();void pic37();void pic38();void pic39();void pic40();void pic41();void pic42();void pic43();void pic44();void pic45();void pic46();void pic47();void picc();3.用户输入以及界面反馈用到的功能函数源代码为int regst(){char num[12],paw1[10],paw2[10],name[10];int i;printf(”请输入账号\n(11字符以内,不能含有中文字符):\n”);password(num,0,11);printf(”输入您的密码\n(9字符以内,不能含有中文字符):\n");password(paw1,1,9);printf("请再次输入密码:\n”);password(paw2,1,9);printf("输入您的姓名:\n");gets(name);system("cls”);i=xzc(num,paw1,paw2,name);return i;}void password(char *a,int b,int j){ char c;int i=0;while((c=getch())!=’\r’){if(c==8){ printf(”\b \b”);if(i〉0)i-—;}else if(i<j){if(b)printf("*”);else printf("%c",c);a[i]=c;i++;}if(i==j){ printf("\a");}}a[i]='\0';printf("\n");}void examine(int *a,int b){ while(!scanf(”%d",a)){ while(getchar()!='\n’);printf("请输入数字!!\n");}rewind(stdin);if(b) system("cls”);}void changepaw(int a,int b){ int i;char c1[10],c2[10],c3[10];printf("请输入原密码\n”);password(c1,1,9);printf("请输入新密码\n");password(c2,1,9);printf(”请再次输入新密码\n”);password(c3,1,9);system("cls”);if(b){i=mp(aa。
C语言课程设计-书店管理系统精选全文

计算机程序设计(C语言)课程设计报告题目:图书管理系统学院:专业:班级:学号:姓名:指导教师:设计日期:2013年06月24日一、选题背景:设计一个图书管理系统,管理员通过登陆账号来进行下一步,使用错误账号和密码会被视为非法登陆。
图书信息包括:每种图书都有书名、ISBN、一名或多名作者(译者)、出版社、定价和内容简介等;读者信息包括:借书证记录有借阅者的姓名、密码、所在单位和类别等;读者凭借书证借书二、设计思想:(1)整个系统除了主函数外,另外还有各种功能子函数,利用无限次循环语句while()和选择语句swithch()实现各个子函数的调用,系统根据输入的数字选项来调用相应的函数,以实现相应的功能。
主要实现了图书的录入、存储、查询、添加、删除、修改、借书、还书等功能。
(2)、Cbook();这是一个指针函数,它主要实现了链表的创建,并且在创建过程中从文件读取信息到链表中,以用于后面其他函数的操作。
它返回的时一个单向链表的头。
其他函数调用时只需调用它返回的头即可。
(3)、mainmenu();、menu1();、glm enu();、cxmenu();、jhmenu();这五个函数时整个图书管理系统的全部菜单函数,mainmenu();为系统主界面,进入时可选择进入程序和退出程序。
menu1();为进程序时显示的功能菜单,在此菜单可以选择录入、保存图书信息,也可选择进入其他子系统。
glmenu();此菜单为进入图书管理系统的菜单,在此可以选择添加、删除、修改图书等操作。
cxmenu();为查询系统的菜单,在此可以选择按书名、编号、作者等方式进行查询图书。
jhmenu();为借书还书的子菜单,在此可以选择借书还书操作。
操作完成后按提示信息进行文件的保存操作。
三、程序流程图会员登陆系统系统管理界面收银系统管理系统报表系统退出系统四、主要解决问题的方法及技术关键通过自己定义的函数和声明一个结构,主要方法是先使用int函数定义,不同的选择进入不同的定义函数,通过for语句进行判断,然后使用heart数组的各种方式打开此文件,然后通过while函数和for函数关闭文件,在不同的取用数值里,分别使用for,while语句进行判断是否进行下条语句。
c语言图书管理系统

int86(0x16, &rg,&rg);
return rg。h。ah;
}
int choose(int bot,int top)/*根据Y的值选择操作*/
{
int ky,y = 7;
gotoxy(30,bot);
do
{
ky = key();
switch(ky)
{
case Key_UP:
gotoxy(x + 1, y + high - 3);
for (i = 1; i < width - 1; i++)
{
putchar(0xc4);
}
gotoxy(x + width—1,y + high —1);
putchar(0xd9);
}
int key()/*读键盘*/
{
union REGS rg;
int halfw(int sum,bbasic binfo[100],char *find);
void sta();
void blist();
void bmoney();
int main(void)
{
menu();
}
void menu()
{
int y;
_window();/*显示窗口*/
words();/*显示菜单文字*/
gotoxy(30,16);
cprintf(”Book Statistic");
gotoxy(30,19);
cprintf(”Exit”);
gotoxy(35,22);
textcolor(LIGHTGRAY);
C语言程序设计大作业--图书管理系统

C语言程序设计大作业设计报告一.设计方案本程序旨在用一个C语言程序实现简单的图书馆图书管理系统,程序包含平时的借书,还书,新书录入,查询功能,用简单明了的人机交互界面快速实现图书管理的目的。
二.模块说明及代码分析1.主函数:源代码:void main(){int a;printf("\n");printf("\n");printf(" ( ^_^ ) WELCOME!\n");printf("\n");printf("\n");printf("\n");printf("\n");printf("\n");printf("\t〉〉-------------BJTU图书管理系统--------------〈〈");printf("\n");printf("\n");printf("\n");printf("\n");printf("\n");printf("\n");printf("\n");do {printf("1.借书 2.还书 3.新书录入4.查询 0.退出");printf("\n");printf("\n");printf("\n");printf("\n");printf("请选择序号:");scanf("%d",&a);switch(a){case 1:jieshu();break;case 2:huanshu();break;case 3:xinshu();break;case 4:chaxun();break;case 0:break;default:printf("请选择正确的序号!\n");printf("\n");}}while(a!=0);printf("谢谢使用图书管理系统!\n");}主函数提供人机交互界面,让操作者选择所需的操作项目,并有退出选项。
c语言课程设计图书馆管理系统

c语言课程设计图书馆管理系统一、教学目标本课程的教学目标是使学生掌握C语言编程基础,能够运用C语言设计简单的图书馆管理系统。
具体分为三个维度:1.知识目标:学生需要掌握C语言的基本语法、数据类型、运算符、控制结构、函数等编程基础。
2.技能目标:学生能够运用C语言进行程序设计,具备编写、调试和运行C语言程序的能力。
3.情感态度价值观目标:培养学生对计算机科学的兴趣,提高学生解决问题的能力,培养学生的创新精神和团队合作意识。
二、教学内容本课程的教学内容主要包括C语言的基本语法、数据类型、运算符、控制结构、函数等编程基础,以及图书馆管理系统的项目实践。
具体安排如下:1.第一章:C语言概述,介绍C语言的历史、特点和基本语法。
2.第二章:数据类型和运算符,学习基本数据类型、字符串、运算符及其优先级。
3.第三章:控制结构,学习条件语句、循环语句和跳转语句。
4.第四章:函数,学习函数的定义、声明和调用,以及常用标准库函数。
5.第五章:数组和字符串,学习一维数组、多维数组、字符串的基本操作。
6.第六章:指针,学习指针的概念、运算和应用。
7.第七章:结构体和文件,学习结构体的定义和应用,以及文件的读写操作。
8.第八章:图书馆管理系统项目实践,运用所学知识设计并实现一个简单的图书馆管理系统。
三、教学方法本课程采用多种教学方法相结合的方式,包括:1.讲授法:讲解C语言的基本语法、数据类型、运算符、控制结构、函数等编程基础。
2.案例分析法:通过分析典型的图书馆管理场景,引导学生运用C语言进行程序设计。
3.实验法:让学生动手编写、调试和运行C语言程序,提高学生的实践能力。
4.小组讨论法:分组进行项目实践,培养学生的团队合作意识和问题解决能力。
四、教学资源1.教材:《C程序设计语言》(K&R)或《C语言 Primer》(第五版)。
2.参考书:《C语言编程思想》、《C语言深度探索》。
3.多媒体资料:课件、教学视频、在线教程。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
程序设计方法课程设计问题提出:设计一个图书馆的图书管理,具体要求如下:1.录入新采购的图书信息,做成文件book.in,要求有良好的输入界面;2.查询各种图书的基本信息,设计出良好的查询界面;3.按图书编号进行排序,将排好序的图书信息输出到文件book.out中。
4.统计各类图书册数、图书馆的图书总册数。
5.统计图书的借阅情况。
1.需求分析对于图书馆的管理系统,应该满足以下的用户需求:○1用户能够增加和删除一些图书。
○2用户根据一些基本信息查询相应的图书,系统可以准确输出所有符合条件的图书信息。
○3用户可以借阅和归还图书馆中的图书。
○4系统可以对图书做出统计,包括图书总数,各类图书数目,图书的借阅情况。
2.设计分析定义图书结构体,其成员包括书名、作者、类型、出版社、价格、是否借阅(整型,1为借出,0为未借)、编号。
输入新书时,利用结构体储存书的信息,同时将新书信息以二进制写入book.in文件中,录入结束后,将新书按输入顺序写入book.out中,并且以原来存书的最大编号为基准对新书进行编号,这样可以保证book.out文件存储的图书都是按编号进行排序的。
查找图书时,获得所查书目基本信息后,以二进制依次读取文件中的每一本图书信息,并与输入信息相比较,输出符合信息的图书。
删除图书时,通过输入的图书编号(编号可通过查找图书获得)查找相应图书,删除相应数据并保存。
借阅或归还图书时,通过图书编号(编号可通过查找图书获得)查找相应图书,修改图书的属性(是否借阅)并保存。
实现统计功能时,以二进制依次读取文件中的每一本图书信息,设置变量统计图书类型、借阅情况和图书总数,到文件结尾时,输出各个变量的值。
3.系统设计(流程图表示)否否4. 程序代码 主函数main(){int i,a;否Struct book standard={"a","a","000000000",0,0,"a","others"}; FILE *fp;if((fp=fopen("book.out","r"))==NULL){if((fp=fopen("book.out","wb"))==NULL){printf("wrong!");exit(0);}fwrite(&standard,sizeof(struct book),1,fp);}fclose(fp);for(i=0;i<=14;i++) /*欢迎界面设置*/{ clrscr();gotoxy(18,25-i);printf("Welcome to Liberary Management System");delay(300000000000);}sleep(1);gotoxy(18,27-i);printf("Press any key to continue");getch();clrscr();while(a!=48) /*打印主菜单*/ { gotoxy(13,5);printf("***********************************************");gotoxy(25,8);printf("1:Add new books");gotoxy(25,10);printf("2:Search books");gotoxy(25,12);printf("3:Delete books");gotoxy(25,14);printf("4:Borrow or return books");gotoxy(25,16);printf("5:Total numbers");gotoxy(25,18);printf("0:Exit");gotoxy(13,21);printf("***********************************************");a=getch() /*调用不同函数实现不同功能*/if(a==49) input_books();if(a==50) search_books();if(a==51) delete_book();if(a==53) total_numbers();if(a==52) br_books();clrscr();}}函数addone和minusone对图书编号进行操作void addone(char ss[]) /*将编号增加一个*/ {int i;if(ss[8]=='9'){ss[8]='0';ss[7]=ss[7]+1;}else ss[8]=ss[8]+1;for(i=7;i>=0;i--)if(ss[i]==58) {ss[i]='0';ss[i-1]++;} }void minusone(char ss[]) /*图书编号减一*/ {int i;if(ss[8]=='0'){ss[8]='9';ss[7]=ss[7]-1;}else ss[8]=ss[8]-1;for(i=7;i>=0;i--)if(ss[i]==47) {ss[i]='9';ss[i-1]--;} }函数save_books()将book.in的数据写入book.out中void save_books() /*保存图书*/ {FILE *fp1,*fp2;struct book oldbook,newbook;char ssl[10];int n,i;if((fp2=fopen("book.out","rb+"))==NULL){printf("wrong!");exit(0);}if((fp1=fopen("book.in","rb"))==NULL){printf("wrong!");exit(0);}fseek(fp2,-100L,2);fread(&oldbook,sizeof(struct book),1,fp2); /*获得目前图书最大编号*/ strcpy(ssl,oldbook.number);fclose(fp2);fseek(fp1,-1L,2);fscanf(fp1,"%d",&n);rewind(fp1);if((fp2=fopen("book.out","ab"))==NULL){printf("wrong!");exit(0);}for(i=1;i<=n;i++){fread(&newbook,sizeof(struct book),1,fp1);addone(ssl);strcpy(newbook.number,ssl); /*为新图书编号*/ fwrite(&newbook,sizeof(struct book),1,fp2);}fclose(fp1);fclose(fp2);}函数input_book将新书的信息读入book.in中void input_books() /*从键盘输入图书函数*/ {FILE *fp;struct book newbook;int a=121,n=0;if((fp=fopen("book.in","wb"))==NULL){printf("wrong!");exit(0);}while(a==121){clrscr();n++;printf("New book %d:\n",n);printf("Name:");scanf("%s",);printf("Author:");scanf("%s",newbook.author);printf("Price:");scanf("%f",&newbook.price);printf("Type:");scanf("%s",newbook.type);printf("Press:");scanf("%s",newbook.press);newbook.isborrowed=0;strcpy(newbook.number,"000000000");fwrite(&newbook,sizeof(struct book),1,fp); /*将图书保存到book.in中*/ printf("continue ? (y/n)");a=getch();}clrscr();fprintf(fp,"%d",n);printf("Successfully saved!\nPress any key to back");fclose(fp);save_books();getch();}函数delete_book实现对图书的删除操作void delete_book() /*删除图书函数*/ {long int totalbook,i;int done=0;char a='y',ss[10];FILE *fp1,*fp2;struct book sbook;clrscr();if((fp1=fopen("book.out","rb"))==NULL){printf("wrong!");exit(0);}if((fp2=fopen("book1.out","wb"))==NULL){printf("wrong!");exit(0);}fseek(fp1,-100L,2);fread(&sbook,sizeof(struct book),1,fp1);totalbook=atol(sbook.number); /*获得图书数目*/ rewind(fp1);while(a==121){clrscr();printf("Please input the number of the book:");scanf("%s",ss);clrscr();fread(&sbook,sizeof(struct book),1,fp1);fwrite(&sbook,sizeof(struct book),1,fp2);for(i=1;i<=totalbook;i+=1){fread(&sbook,sizeof(struct book),1,fp1); /*删除操作*/if(strcmp(sbook.number,ss)==0) /*将删除过相应图书的数据写入book1.out*/ {done=1;printf("The information of the book:\n");printf("Name:%s\n",);printf("Author:%s\n",sbook.author);printf("Number:%s\n",sbook.number);printf("Price:%-9.2f\n",sbook.price);printf("Press:%s\n",sbook.press);printf("Are you sure to delete the book?(y/n)") ;a=getch();if(a!=121) break;}else{if(done==0) fwrite(&sbook,sizeof(struct book),1,fp2);else {minusone(sbook.number);fwrite(&sbook,sizeof(struct book),1,fp2);}}}fclose(fp1);fclose(fp2);if(done==0) printf("Wrong number!");if(done==1 && a==121){ exchange(i,totalbook);clrscr();printf("Successfully deleted!\n");}getch();clrscr();printf("Continue ? (y/n)");a=getch();}remove("book1.out");}void exchange(long int i,long int totalbook) /*将book1.out的数据写入book.out中*/ {FILE *fp1,*fp2;struct book sbook;if((fp1=fopen("book1.out","rb"))==NULL){printf("wrong!");exit(0);}fp2=fopen("book.out","wb");for(i=1;i<=totalbook;i+=1){fread(&sbook,sizeof(struct book),1,fp1);fwrite(&sbook,sizeof(struct book),1,fp2);}fclose(fp1);fclose(fp2);}函数search_books实现对图书的查找void search_books() /*查找图书函数*/{int n,total=0;long int totalbook,i;char item[20];char ss='y';FILE *fp;struct book sbook;if((fp=fopen("book.out","rb"))==NULL){printf("wrong!");exit(0);}fseek(fp,-100L,2);fread(&sbook,sizeof(struct book),1,fp);totalbook=atol(sbook.number);fseek(fp,100L,0);while(ss==121){clrscr();printf("Please select a way to search:\n"); /*查找方式设置*/ printf("1:name\n2:author\n3:number\n");n=getch();switch(n){case 49:clrscr();printf("Please input the name of the book:\n");scanf("%s",item);clrscr();printf("\n");for(i=1;i<=totalbook;i+=1){fread(&sbook,sizeof(struct book),1,fp);if(strcmp(,item)==0) /*打印图书信息*/ {printf("Book %d\n",total+1);printf("Name:%s\n",);printf("Author:%s\n",sbook.author);printf("Number:%s\n",sbook.number);printf("Price:%-9.2f\n",sbook.price);printf("Press:%s\n",sbook.press);printf("Type:%s\n",sbook.type);printf("Isborrowed:%d\n\n",sbook.isborrowed);total++;continue;}}gotoxy(1,1);if(total==0) printf("No such book!"); /*没有对应图书*/ else printf("We find %d books totally:",total);getch();break;case 50:clrscr();printf("Please input the author of the book:\n");scanf("%s",item);clrscr();printf("\n");for(i=1;i<=totalbook;i+=1){fread(&sbook,sizeof(struct book),1,fp);if(strcmp(sbook.author,item)==0) {printf("Book %d\n",total+1);printf("Name:%s\n",);printf("Author:%s\n",sbook.author);printf("Number:%s\n",sbook.number);printf("Price:%-9.2f\n",sbook.price);printf("Press:%s\n",sbook.press);printf("Isborrowed:%d\n\n",sbook.isborrowed);total++;continue;}}gotoxy(1,1);if(total==0) printf("No such book!");else printf("We find %d books totally:",total);getch();break;case 51:clrscr();printf("Please input the number of the book:\n");scanf("%s",item);clrscr();printf("\n");for(i=1;i<=totalbook;i+=1){fread(&sbook,sizeof(struct book),1,fp);if(strcmp(sbook.number,item)==0) {printf("Book %d\n",total+1);printf("Name:%s\n",);printf("Author:%s\n",sbook.author);printf("Number:%s\n",sbook.number);printf("Price:%-9.2f\n",sbook.price);printf("Press:%s\n",sbook.press);printf("Isborrowed:%d\n\n",sbook.isborrowed);total++;continue;}}gotoxy(1,1);if(total==0) printf("No such book!");else printf("We find %d books totally:",total);getch();break;}total=0;clrscr();printf("continue ? (y/n):\n");ss=getch();}fclose(fp);}函数br_books实现对图书的借阅和归还void br_books() /*借阅或归还图书函数*/ {int done=0;char a='y',number[10];FILE *fp;long int i,totalbook;struct book sbook;if((fp=fopen("book.out","rb+"))==NULL){printf("wrong!");exit(0);}fseek(fp,-100L,2);fread(&sbook,sizeof(struct book),1,fp);totalbook=atol(sbook.number);fseek(fp,100L,0);while(a==121){clrscr();printf("Please input a kind of service:\n");printf("1:Borrow a book\n2:Return a book\n"); /*选择相应服务*/ a=getch();if(a==49){clrscr();printf("Please input the number of the book:");scanf("%s",number);clrscr();for(i=0;i<=totalbook;i+=1){fread(&sbook,sizeof(struct book),1,fp);if(strcmp(sbook.number,number)==0){if(sbook.isborrowed==0) {printf("The information of the book:\n");printf("Name:%s\n",);printf("Author:%s\n",sbook.author);printf("Number:%s\n",sbook.number);printf("Price:%-9.2f\n",sbook.price);printf("Press:%s\n",sbook.press);printf("Are you sure to borrow the book?(y/n)") ; /*确认操作*/ a=getch();if(a==121){sbook.isborrowed=1;fseek(fp,-100L,1);fwrite(&sbook,sizeof(struct book),1,fp);fclose(fp);clrscr();printf("Successfully borrowed!");}}else {printf("This book has been borrowed!");fclose(fp);}done=1;break; } }if(done==0){ printf("Wrong number!");fclose(fp);}}if(a==50){clrscr();printf("Please input the number of the book:");scanf("%s",number);clrscr();for(i=0;i<=totalbook;i+=1){fread(&sbook,sizeof(struct book),1,fp);if(strcmp(sbook.number,number)==0){if(sbook.isborrowed==1) {printf("The information of the book:\n");printf("Name:%s\n",);printf("Author:%s\n",sbook.author);printf("Number:%s\n",sbook.number);printf("Price:%-9.2f\n",sbook.price);printf("Press:%s\n",sbook.press);printf("Are you sure to return the book?(y/n)") ; a=getch();if(a==121){sbook.isborrowed=0;fseek(fp,-100L,1);fwrite(&sbook,sizeof(struct book),1,fp);fclose(fp);clrscr();printf("Successfully returned!");}}else {printf("This book has not been borrowed!"); fclose(fp);}done=1;break;} }if(done==0){ printf("Wrong number!");fclose(fp);}} getch();clrscr();printf("\ncontinue ?(y/n) \n");a=getch();}}函数total_numbers实现图书统计操作void total_numbers(){FILE *fp;long int totalbook;long int hasb=0,typs=0,typl=0,i;struct book sbook;clrscr();if((fp=fopen("book.out","rb"))==NULL){printf("wrong!");exit(0);}fseek(fp,-100L,2);fread(&sbook,sizeof(struct book),1,fp);totalbook=atol(sbook.number);printf("The total number of all books is:%ld\n",totalbook);rewind(fp);for(i=1;i<=totalbook;i+=1) /*统计图书类型*/{fread(&sbook,sizeof(struct book),1,fp);if(strcmp("science",sbook.type)==0)typs+=1;else if(strcmp("literature",sbook.type)==0)typl+=1;if(sbook.isborrowed==1) hasb+=1;} /*统计借阅情况*/printf("The different numbers of types:\n");printf("science:%ld\n",typs);printf("literature:%ld\n",typl);printf("others:%ld\n\n",totalbook-typs-typl);printf("The number of books have borrowed:%ld\n",hasb);printf("The number of books have not been borrowed:%ld\n",totalbook-hasb);fclose(fp);getch();}5.系统测试系统主菜单视图效果如下:对于该系统输入三本书,基本信息如下:Book1:名称:math作者:ma价格:29.4出版社:xjtup类型:scienceBook2:名称:c作者:yuyan价格:13出版社:xjtup类型:scienceBook3:名称:physics作者:ren价格:25.7出版社:xjtup类型:science图书统计情况:查找名称为c的图书删除第一本书和借阅第二本书后的统计情况:总结:通过一系列的测试可发现该系统可以基本满足客户的各种需求,同时输入输出界面比较简洁,是一个比较成功的系统,但同时也存在一些问题需要改进,主要有以下几个方面:1.使用scanf输入不能输入带有空格的字符串2.在使用编号进行图书查询时会发生一些错误,可能会出现查找图书多余实际图书的情况。