C语言程序设计大作业--图书管理系统

合集下载

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语言程序设计报告--图书管理系统_第二组

c语言程序设计报告--图书管理系统_第二组

C语言课程设计报告图书信息管理系统设计第二组指导老师:韩晶C语言程序设计C语言程序设计实践是学习C语言的重要一环。

在实践中我们运用所有所学的C语言知识完成此次项目。

任何上机实践都增强我们对C语言的理解及运用能力。

虽然此次项目对我们初学者来说是一个巨大的工程,但组员之间的合作让我们顺利解决了各种难题。

谨以此成果献给所有费尽心血的第二小组成员及不断给予指导的韩老师。

一.题目要求1.设计题目:图书信息管理系统2.图书信息包括:登录号、书名、作者名、分类号、出版单位、出版时间、价格3.系统实现以下功能:1)系统以菜单方式工作。

2)图书信息录入功能——输入。

3)图书信息浏览功能——输出。

4)查询和排序功能:(1)按书名查询(2)按作者名查询(3)按登录号排序(4)按图书价钱排序5)图书信息的删除与修改。

二.设计分析概括根据题目要求分析可知我们需要程序提供一个结构体及文件的输入输出功能。

图书信息以结构体的形式存入固定文件中,在此基础上实现图书信息的浏览,查询和排序,删除与修改功能。

并将各种功能分为不同的子程序,在主程序上进行调用及运行。

程序界面菜单以键盘输入选择的方式来运行各种功能。

三.总体设计根据题目要求将程序分为以下部分:1.管理员登陆系统模块2.菜单选择模块3.图书信息录入功能模块4.图书信息浏览功能模块5.图书信息查询功能模块6.图书信息的删除与修改模块四.具体编程#include<stdio.h>typedef struct bkInfo /*图书信息结构体*/{char idNum[20]; /*图书编号*/char bkName[20]; /*书名*/char writer[10]; /*作者名*/char press[10]; /*出版社*/char pubTime[10]; /*出版时间*/char price[10]; /*价格*/char claNum[14]; /*分类号*/} ;#define x 4#define y 6int main(){void menua(); /*管理员菜单*/void menub(); /*读者菜单*/void bkadd(); /*图书信息添加*/int choice1,chlan;int choice2,idcode=1615,passcode=123,idcheck,passcheck;clrscr();1.登录菜单printf("\n==============================================================");printf("\n ||\t\t\t\t\t\t\t\t ||");printf("\n ||\t\t *** WELCOME TO THE *** ||");printf("\n ||\t\t\t\t\t\t\t\t ||");printf("\n || UNITED ADMINISTRATION AND INQUIRY OF BOOK INFORMATION ||"); printf("\n ||\t\t\t\t\t\t\t\t ||");printf("\n ||\t\t *** STANDERD SYSTEM *** \t\t ||");printf("\n ||\t\t\t ( ALPHA-X-%d.%d )\t\t\t ||",x,y);printf("\n ||\t\t\t\t\t\t\t\t ||");printf("\n ||\t\t\tpowered by Group II \t\t\t ||");printf("\n ||\t\t\t\t\t\t\t\t ||");printf("\n==============================================================");printf("\n\n\t ---------------------------------------");printf("\n\t\t >>> ENTER THE SYSTEM? Y/N <<<");printf("\n\t ---------------------------------------\n");printf("\n\n\t[] Enter 1 for YES or 2 for NO"); /*是否选择进入*/printf("\n\nYOU CHOOSE:");scanf("%d",&choice1);2.管理员模式/读者模式进入while(choice1!=1&&choice1!=2) /*选择号错误*/{printf("\n\n\t[] Unidentified option,please recheck!");printf("\n\t[] Enter 1 for YES or 2 for NO");printf("\n\nYOU CHOOSE:");scanf("%d",&choice1);}switch(choice1){case 1: /*选择进入系统*/printf("\n\n\t\t ACCESS confirmed loading...");printf("\n\n\t[] Is this an Administrator Visit or a General Visit?");printf("\n\n\t[] Enter 1 for your Administrator Visit or 2 for the other.\n\n"); printf("\nYOU CHOOSE:"); /*选择管理员模式或读者模式*/ scanf("%d",&choice2);while(choice2!=1&&choice2!=2) /*进入模式选择号错误*/ {printf("\n\n\t[] Unidentified option,please recheck!");printf("\n\t[] Enter 1 for your Administrator Visit or 2 for the other.");printf("\n\nYOU CHOOSE:");scanf("%d",&choice2);}if(choice2==1) /*进入管理员模式*/{printf("\n\n\t ----------------------------------------------------");printf("\n\t LOGIN >>>please enter your ID CODE & PASSWORD<<<");printf("\n\t ----------------------------------------------------\n");printf("\nYOUR ID:");scanf("%d",&idcheck);printf("\nPASSWORD:");scanf("%d",&passcheck);while(idcheck!=idcode || passcheck!=passcode)/*通行证与密码错误*/ {printf("\n\n\t[] Unidentified ID or wrong PASSWORD,ACCESS refused,please recheck!");printf("\n\t[] please enter your ID CODE & PASSWORD");printf("\n\nYOUR ID:");scanf("%d",&idcheck);printf("\nPASSWORD:");scanf("%d",&passcheck);}if(idcheck==idcode && passcheck==passcode)/*进入管理员模式菜单*/ {printf("\n\n\n\n\t[] ACCESS for Noble Class has been authorisedloading...");printf("\n\n\t[] Administor System at your service !");printf("\n\n\n\t[] Please choose a language service: 1.Chinese 2.English3.French");printf("\n\nYOU CHOOSE:"); /*语言选择*/scanf("%d",&chlan);while(chlan!=2){if(chlan>3){printf("\n\n\t[] Unidentified option,please recheck!");printf("\n\t[] Please choose a language service: 1.Chinese 2.English3.French");}else{printf("\n\n\t[] ERROR: NO LANGUAGE PACKAGE HAS BEEN FOUND !");printf("\n\t[] Please choose a language service: 1.Chinese 2.English3.French");}printf("\n\nYOU CHOOSE:");scanf("%d",&chlan);}if(chlan==2){menua();}}}if(choice2==2) /*进入读者模式*/{printf("\n\n\n\n\t[] OPTION CONFIRMED,LANGUAGE PACKAGE is laoding...please wait...\n");printf("\n\t[] ACCESS authorised loading...");printf("\n\n\t[] Visitor System operational...");menub();}break;case 2: /*选择不进入系统*/printf("\n\n\t\t\t\t ***QUIT***");printf("\n\t\t\tTHANKS FOR USING,SO LONG !!!\n");printf("\n\n UNITED ADMINISTRATION AND INQUIRY OF BOOK INFORMATION-STANDERD SYSTEM-%d.%d",x,y);printf("\n\t\t powered by Group II in 3.2012");printf("\n\n\n\t\t\t SPECIAL THANKS FOR\n");printf("\n\t[] Peter Horuce ^_^ for Main Function & Debugging");printf("\n\t[] WangYueWei ^_^ for Program Design & ...");printf("\n\t[] ZhangYanDong ^_^ for Book Data Input Function");printf("\n\t[] ZhangBeiBei ^_^ for the ...");printf("\n\t[] GuoXinYu ^_^ for the ...");printf("\n\t[] SongShaoXiu ^_^ for the ...");printf("\n\t[] GuLingKai ^_^ for the ...");printf("\n\t[] ZhenYiFeng ^_^ for the ...");printf("\n\t[] WangJieYao ^_^ for the ...");printf("\n\t[] LiLuZi ^_^ for the ...");printf("\n\t[] WangSanHu ^_^ for the ...");printf("\n\t[] HuangFangHao ^_^ for the ...");printf("\n");getch();break;}return 0;}3.管理员模式系统void menua(){int ch,out;printf("\n\n\n\t[] OPTION CONFIRMED,LANGUAGE PACKAGE is laoding...please wait...\n\n");printf("\n\t\t*********************************");printf("\n\t\t*\t\t\t\t*");printf("\n\t\t* CENTRAL BOOK ADMINISTRATION *");printf("\n\t\t*\t\t\t\t*");printf("\n\t\t*********************************\n\n");printf("\t\t\t <<< M E N U >>>\n\n");printf("\t\t 1.Book Data Input\t2.bkamend\n\n");printf("\t\t 3.bkdelete\t\t4.bkorder\n\n");printf("\t\t 5.bksearch\t\t6.bkview\n\n");printf("\t\t 7.QUIT\n\n\n");printf("PLEASE CHOOSE A SERVICE:");scanf("%d",&ch); /*服务选择*/while(ch>7){printf("\n\n\t[] Unidentified option,please recheck!\n");printf("\n\nPLEASE CHOOSE A SERVICE:");scanf("%d",&ch);}switch(ch){case 1:printf("\n\t[] As you wish!\n");bkadd();break;case 2:printf("\n\t[] As you wish!\n");break;case 3:printf("\n\t[] As you wish!\n");break;case 4:printf("\n\t[] As you wish!\n");break;case 5:printf("\n\t[] As you wish!\n");break;case 6:printf("\n\t[] As you wish!\n");break;case 7:printf("\n\n\t\t\t\t ***QUIT***");printf("\n\t\t\tTHANKS FOR USING,SO LONG !!!\n");printf("\n\n UNITED ADMINISTRATION AND INQUIRY OF BOOK INFORMATION-STANDERD SYSTEM-%d.&d",x,y);printf("\n\t\t powered by Group II in 3.2012");printf("\n\n\n\t\t\t SPECIAL THANKS FOR\n");printf("\n\t[] Peter Horuce ^_^ for Main Function & Debugging");printf("\n\t[] WangYueWei ^_^ for Program Design & ...");printf("\n\t[] ZhangYanDong ^_^ for Book Data Input Function");printf("\n\t[] ZhangBeiBei ^_^ for the ...");printf("\n\t[] GuoXinYu ^_^ for the ...");printf("\n\t[] SongShaoXiu ^_^ for the ...");printf("\n\t[] GuLingKai ^_^ for the ...");printf("\n\t[] ZhenYiFeng ^_^ for the ...");printf("\n\t[] WangJieYao ^_^ for the ...");printf("\n\t[] LiLuZi ^_^ for the ...");printf("\n\t[] WangSanHu ^_^ for the ...");printf("\n\t[] HuangFangHao ^_^ for the ...");printf("\n");getch();break;}}4.读者模式系统void menub(){int cho,out;printf("\n\n\n\t\t ***** INQUIRY OF BOOK INFORMATION *****");printf("\n--------------------------------------------------------------------------------");printf("\n\n\t\t\t <<< M E N U >>>\n\n");printf("\t\t 1.[restricted]\t 2.[restricted]\n\n");printf("\t\t 3.[restricted]\t 4.[restricted]\n\n");printf("\t\t 5.bksearch\t\t 6.bkview\n\n");printf("\t\t 7.QUIT\n\n\n");printf("PLEASE CHOOSE A SERVICE:");scanf("%d",&cho); /*服务选择*/while(cho>7 || cho<5){if(cho>7)printf("\n\n\t[] Unidentified option,please recheck!\n");if(cho>=1 && cho<=4)printf("\n\n\t[] Restricted option! You are not an authorised administor!\n"); printf("\n\nPLEASE CHOOSE A SERVICE:");scanf("%d",&cho);}switch(cho){case 5:break;case 6:break;case 7:printf("\n\n\t\t\t\t ***QUIT***");printf("\n\t\t\tTHANKS FOR USING,SO LONG !!!\n");printf("\n\n UNITED ADMINISTRATION AND INQUIRY OF BOOK INFORMATION-STANDERD SYSTEM-%d.&d",x,y);printf("\n\t\t powered by Group II in 3.2012");printf("\n\n\n\t\t\t SPECIAL THANKS FOR\n");printf("\n\t[] Peter Horuce ^_^ for Main Function & Debugging");printf("\n\t[] WangYueWei ^_^ for Program Design & ...");printf("\n\t[] ZhangYanDong ^_^ for Book Data Input Function");printf("\n\t[] ZhangBeiBei ^_^ for the ...");printf("\n\t[] GuoXinYu ^_^ for the ...");printf("\n\t[] SongShaoXiu ^_^ for the ...");printf("\n\t[] GuLingKai ^_^ for the ...");printf("\n\t[] ZhenYiFeng ^_^ for the ...");printf("\n\t[] WangJieYao ^_^ for the ...");printf("\n\t[] LiLuZi ^_^ for the ...");printf("\n\t[] WangSanHu ^_^ for the ...");printf("\n\t[] HuangFangHao ^_^ for the ...");printf("\n");getch();break;}}5.图书添加void bkadd(){struct bkInfo book;FILE *fp;int n,i,j;char message[2];if((fp=fopen("e:\\bkInfo.txt","a"))==NULL){if((fp=fopen("e:\\bkInfo.txt","w"))==NULL){printf("Failed to open the file\n");return;}}printf("\n\n\n\t\t==========================\n");printf("\t\t Book Information Input \n");printf("\t\t==========================\n\n");printf("\t[] The number of your books that are to write in is(are):");scanf("%d",&n);gets(message);for(i=1;i<=n;i++){printf("\n\n\t[] Now please write in the info:\n\n\n");printf("\t1.BOOK'S ID: ");gets(book.idNum);printf("\t2.BOOK'S NAME: ");gets(book.bkName);printf("\t3.AUTHOR'S NAME: ");gets(book.writer);printf("\t4.PRESS OF BOOK: ");gets(book.press);printf("\t5.BOOK'S PRICE: ");gets(book.price);printf("\t6.PUBLISHED TIME: ");gets(book.pubTime);printf("\t7.CLASSIFICATION: ");gets(book.claNum);fprintf(fp,"%s %s %s %s %s %s %s\n",&book.idNum,&book.bkName,&book.writer, &book.press,&book.price,&book.pubTime,&book.claNum);}printf("\n\n\n\t[] All data have been saved!\n\n\t[] Back to MENU(1) or just QUIT(2) ?");printf("\n\nYOU CHOOSE:"); /*服务选择*/scanf("%d",&j);while(j!=1&&j!=2){printf("\n\n\t[] Unidentified option,please recheck!");printf("\n\t[] Enter 1 for MENU or 2 for QUIT");printf("\n\nYOU CHOOSE:");scanf("%d",&j);}if(j==1) /*返回菜单*/{printf("\n");menua();}if(j==2) /*选择结束*/{ printf("\n\n\t\t\t\t ***QUIT***");printf("\n\t\t\tTHANKS FOR USING,SO LONG !!!\n");printf("\n\n UNITED ADMINISTRATION AND INQUIRY OF BOOK INFORMATION-STANDERD SYSTEM-%d.&d",x,y);printf("\n\t\t powered by Group II in 3.2012");printf("\n\n\n\t\t\t SPECIAL THANKS FOR\n");printf("\n\t[] Peter Horuce ^_^ for Main Function & Debugging");printf("\n\t[] WangYueWei ^_^ for Program Design & ...");printf("\n\t[] ZhangYanDong ^_^ for Book Data Input Function");printf("\n\t[] ZhangBeiBei ^_^ for the ...");printf("\n\t[] GuoXinYu ^_^ for the ...");printf("\n\t[] SongShaoXiu ^_^ for the ...");printf("\n\t[] GuLingKai ^_^ for the ...");printf("\n\t[] ZhenYiFeng ^_^ for the ...");printf("\n\t[] WangJieYao ^_^ for the ...");printf("\n\t[] LiLuZi ^_^ for the ...");printf("\n\t[] WangSanHu ^_^ for the ...");printf("\n\t[] HuangFangHao ^_^ for the ...");printf("\n");getch();}fclose(fp);}五.后记1. 课程设计中遇到的主要问题和解决方法2. 创新和得意之处•界面美观•管理员有固定的登录名和密码•有语言包的选择:满足大部分人群需求•管理员和读者都可登录:系统包容性大•错选反馈:人机交互性强•一次性多重输入:方便操作•退出送别3. 设计中存在的不足及改进的设想由于编译器的局限,我们未能实现语言多重化的目标,目前系统中只存在英文版本。

图书馆管理系统C语言程序设计

图书馆管理系统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语言程序

#include<stdio.h>/*输入输出函数*/#include<string.h>/*字符串操作函数*/#include<stdlib.h>/*数值转换函数*///#include<conio.h>/*控制台输入输出函数*/#define MAX 100/*宏定义,参数为形参*/struct book/*图书信息结构定义*/{intnum;/*图书编号*/char name[100];/*书名*/char author[100];/*作者名*/char fn[100];/*分类号*/char place[100];/*出版单位*/char day[100];/*出版时间*/float money;/*价格*/}book[MAX],temp;main()/*主函数*/{void Input();/*输入*/void Output();/*输出*/void Find();/*查找*/void Delete();/*删除*/void Change();/*修改*/void Paixu();/*排序*/int n;printf("\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※欢迎来河南工业大学图书信息管理系统※\n");printf("※※\n");printf("※※\n");printf("※★1.图书管理员系统★※\n");printf("※※\n");printf("※★2.读者系统★※\n");printf("※※\n");printf("※▲退出(输入其他数字)※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("请输入选择项(1-2):");scanf("%d",&n);printf("\n\n\n\n");if(n==1){int m;printf("请输入图书管理系统的密码:");scanf("%d",&m);if(m==1002){for(;;)/*省略"初始化"、"条件表达式"和"增量"*/{int s;printf("\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※欢迎来河南工业大学图书信息管理系统※\n");printf("※※\n");printf("※※\n");printf("※主菜单※\n");printf("※※\n");printf("※★1.图书信息录入★※\n");printf("※※\n");printf("※★2.图书信息浏览★※\n");printf("※※\n");printf("※★3.图书信息查询★※\n");printf("※※\n");printf("※★4.图书信息删除★※\n");printf("※※\n");printf("※★5.图书信息修改★※\n");printf("※※\n");printf("※★6.图书排序★※\n");printf("※※\n");printf("※★7.退出系统★※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n\n");printf("请输入选择项(1-7):");scanf("%d",&s);printf("\n\n\n\n");if(s>0&&s<8){switch(s){case 1:Input();break;case 2:Output();break;case 3:Find();break;case 4:Delete();break;case 5:Change();break;case 6:Paixu();break;case 7:printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※谢谢使用! ※\n");printf("※再见! ※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");exit(0);}}}}elseprintf("密码错误,请您重新进入系统\n");return 0;}else if(n==2){int t;printf("请输入读者密码:");scanf("%d",&t);if(t==.320){for(;;)/*省略"初始化"、"条件表达式"和"增量"*/{int h;printf("\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※欢迎来河南工业大学图书服务系统※\n");printf("※※\n");printf("※※\n");printf("※主菜单※\n");printf("※※\n");printf("※★1.图书信息浏览★※\n");printf("※※\n");printf("※★2.图书信息查询★※\n");printf("※※\n");printf("※★3.图书排序★※\n");printf("※※\n");printf("※★4.退出系统★※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n\n");printf("请输入选择项(1-4):");scanf("%d",&h);printf("\n\n\n\n");if(h>0&&h<5){switch(h){case 1:Output();break;case 2:Find();break;case 3:Paixu();break;case 4:printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※谢谢使用! ※\n");printf("※再见! ※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");exit(0);}}}}elseprintf("密码错误,请您重新进入系统\n");return 0;}else return 0;}void Find()/*查找*/{int i;intchoose,t;charans[100];do{printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※※\n");printf("※ 1.按书名查找※\n");printf("※ 2.按作者名查找※\n");printf("※▲返回主菜单(输入其他数字)※\n");printf("※※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("输入选项代号:");scanf("%d",&choose);if(choose==1){printf("输入所查书名:\n");scanf("%s",ans);t=-1;if(choose==1){for(i=0;i<MAX;i++)if(strcmp(ans,book[i].name)==0){t=i;printf("%d %s %s %s %s %s %2f\n",book[t].num,book[t].name,book[t].author,bo ok[t].fn,book[t].place,book[t].day,book[t].money);}}if(t==-1)printf("不存在该信息\n");}else if(choose==2){printf("输入所查作者名:\n");scanf("%s",ans);t=-1;if(choose==2){for(i=0;i<MAX;i++)if(strcmp(ans,book[i].author)==0){t=i;printf("%d %s %s %s %s %s %2f\n",book[t].num,book[t].name,book[t].author,bo ok[t].fn,book[t].place,book[t].day,book[t].money);}}if(t==-1) printf("不存在该信息\n");}else return;}while(1);}void Output()/*输出*/{FILE *fp;int i;fp=fopen("book","rb");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;fread(&book[i],sizeof(struct book),1,fp)==1;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i]. author,book[i].fn,book[i].place,book[i].day,book[i].money);}fclose(fp);}void Input()/*输入*/{FILE *fp;int n;fp=fopen("book","ab");/*建立一个新二进制文件*/for(n=0;n<MAX;n++){printf("n=%d 输入序号n(当输入n=-1时,返回),n=",n++);scanf("%d",&n);if(n==-1){fclose(fp);return;/*默认不返回值*/}else{printf("请输入图书编号书名作者名分类号出版单位出版时间价格\n");scanf("%d%s%s%s%s%s%f",&book[n].num,book[n].name,book[n].author,book[n ].fn,book[n].place,book[n].day,&book[n].money);fwrite(&book[n],sizeof(struct book),1,fp);/*写入文件*/}}fclose(fp);}void Delete()/*删除*/{FILE *fp;inti,flag,n,s,j;fp=fopen("book","rb+");rewind(fp);printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;fread(&book[i],sizeof(struct book),1,fp)==1;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);printf("\n");}n=i;printf("输入待删除图书编号:\n");scanf("%d",&s);for(i=0,flag=1;flag&&i<n;i++){if(s==book[i].num){for(j=i;j<n-1;j++){book[j].num=book[j+1].num;strcpy(book[j].name,book[j+1].name);strcpy(book[j].author,book[j+1].author);strcpy(book[j].fn,book[j+1].fn);strcpy(book[j].place,book[j+1].place);strcpy(book[j].day,book[j+1].day);book[j].money=book[j+1].money;}flag=0;}}if(!flag)n=n-1;elseprintf("没有此号\n");fp=fopen("book","wb");for(i=0;i<n;i++)fwrite(&book[i],sizeof(struct book),1,fp);fclose(fp);fp=fopen("book","r");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;i<n;i++){fread(&book[i],sizeof(struct book),1,fp);printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);printf("\n");}fclose(fp);}void Change()/*修改*/{FILE *fp;inti,num,n;int flag=0;printf("请输入要修改的图书编号:");scanf("%d",&num);for(i=0;i<=MAX;i++)if(book[i].num==num){printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);printf("-----------------------------------------------------------\n\n");n=i;flag=1;break;}if(flag==0){printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf("※输入错误! ※\n");printf("※请返回! ※\n");printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");return;}printf("\n\n\n");fp=fopen("book","rb+");fseek(fp,n*sizeof(struct book),0);printf("图书编号书名作者名分类号出版单位出版时间价格\n");scanf("%d%s%s%s%s%s%f",&book[n].num,book[n].name,book[n].author,book[n].fn, book[n].place,book[n].day,&book[n].money);fwrite(&book[i],sizeof(struct book),1,fp);fclose(fp);fp=fopen("book","rb");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");printf("-----------------------------------------------------------\n");for(i=0;fread(&book[i],sizeof(struct book),1,fp)==1;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i].auth or,book[i].fn,book[i].place,book[i].day,book[i].money);}printf("-----------------------------------------------------------\n\n");fclose(fp);}void Paixu()/*排序*/{FILE *fp;inti,max,s;fp=fopen("book","rb");for(s=0;fread(&book[s],sizeof(struct book),1,fp)==1;s++);for(i=0;i<s-i;i++){if(book[i].money>book[i+1].money){max=i;temp=book[i];book[i]=book[i+1];book[i+1]=temp;}}printf("※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※\n");printf(" 图书列表\n");printf("-----------------------------------------------------------\n");printf("图书编号书名作者名分类号出版单位出版时间价格\n");for(i=0;i<s;i++){printf("%6d %8s %8s %8s %8s %8s %10.2f\n",book[i].num,book[i].name,book[i]. author,book[i].fn,book[i].place,book[i].day,book[i].money);}printf("-----------------------------------------------------------\n");getchar();}。

C语言程序设计大作业--图书管理系统

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语言程序设计图书馆管理系统一、分析过程首先此程序需要实现输入、增加、删除、查询、输出的五大功能,则首先需要设置一个菜单键,让用户可以选择不同的功能,完成不同的操作,然后编写不同的函数实现不同的功能,在这个过程中注意要人性化,让用户方便,直观的进行操作。

二、算法三、函数模块介绍1录入模块:本模块主要执行信息的录入功能2浏览模块:本模块主要是执行把已有信息输出浏览功能3查询模块:本模块主要是按照图书名查找图书的相关信息4删除模块:主要是执行删除图书信息的功能5退出模块:方便用户离开四、源程序#include<stdio.h>#include<math.h>#include<string.h>#include<stdlib.h>struct books_list{char author[20]; /*作者名*/char bookname[20]; /*书名*/char publisher[20]; /*出版单位*/char pbtime[15]; /*出版时间*/char loginnum[10]; /*登陆号*/float price; /*价格*/char classfy[10]; /*分类号*/struct books_list * next; /*链表的指针域*/};struct books_list * Create_Books_Doc(); /*新建链表*/ void InsertDoc(struct books_list * head); /*插入*/void DeleteDoc(struct books_list * head , int num);/*删除*/ void Print_Book_Doc(struct books_list * head);/*浏览*/void search_book(struct books_list * head); /*查询*/void save(struct books_list * head);/*保存数据至文件*//*新建链表头节点*/struct books_list * Create_Books_Doc(){struct books_list * head;head=(struct books_list *)malloc(sizeof(struct books_list)); /*分配头节点空间*/head->next=NULL; /*头节点指针域初始化,定为空*/return head;}/*保存数据至文件*/void save(struct books_list * head){struct books_list *p;FILE *fp;p=head;fp=fopen("data.txt","w+"); /*以写方式新建并打开 data.txt文件*/fprintf(fp,"┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━┳━━━━┓\n"); /*向文件输出表格*/fprintf(fp,"┃登录号┃书名┃作者┃出版单位┃出版时间┃分类号┃价格┃\n");fprintf(fp,"┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━╋━━━━┫\n");/*指针从头节点开始移动,遍历至尾结点,依次输出图书信息*/while(p->next!= NULL){p=p->next;fprintf(fp,"┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s┃%-12.12s┃%-6.6s┃%.2f ┃\n",p->loginnum,p->bookname,p->author,p->publisher,p->pbtime,p->classfy,p->pric e);}fprintf(fp,"┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━┻━━━━┛\n");fclose(fp);printf(" 已将图书数据保存到 data.txt 文件\n");}/*插入*/void InsertDoc(struct books_list *head){/*定义结构体指针变量 s指向开辟的新结点首地址 p为中间变量*/struct books_list *s, *p;char flag='Y'; /*定义flag,方便用户选择重复输入*/p=head;/*遍历到尾结点,p指向尾结点*/while(p->next!= NULL){p=p->next;}/*开辟新空间,存入数据,添加进链表*/while(flag=='Y'||flag=='y'){s=(struct books_list *)malloc(sizeof(struct books_list)); printf("\n 请输入图书登陆号:");fflush(stdin);scanf("%s",s->loginnum);printf("\n 请输入图书书名:");fflush(stdin);scanf("%s",s->bookname);printf("\n 请输入图书作者名:");fflush(stdin);scanf("%s",s->author);printf("\n 请输入图书出版社:");fflush(stdin);scanf("%s",s->publisher);printf("\n 请输入图书出版时间:");fflush(stdin);scanf("%s",s->pbtime);printf("\n 请输入图书分类号:");fflush(stdin);scanf("%s",s->classfy);printf("\n 请输入图书价格:");fflush(stdin);scanf("%f",&s->price);printf("\n");p->next=s; /*将新增加的节点添加进链表*/p=s; /*p指向尾节点,向后移*/s->next=NULL;printf(" ━━━━添加成功!━━━━"); printf("\n 继续添加?(Y/N):"); fflush(stdin);scanf("%c",&flag);printf("\n");if(flag=='N'||flag=='n'){break;}else if(flag=='Y'||flag=='y'){continue;}}save(head); /*保存数据至文件*/return;}/*查询操作*/void search_book(struct books_list *head){struct books_list * p;char temp[20];p=head;if(head==NULL || head->next==NULL) /*判断数据库是否为空*/ {printf(" ━━━━图书库为空!━━━━\n");}else{printf("请输入您要查找的书名: ");fflush(stdin);scanf("%s",temp);/*指针从头节点开始移动,遍历至尾结点,查找书目信息*/while(p->next!= NULL){p=p->next;if(strcmp(p->bookname,temp)==0){printf("\n图书已找到!\n");printf("\n");printf("登录号: %s\t\n",p->loginnum);printf("书名: %s\t\n",p->bookname);printf("作者名: %s\t\n",p->author);printf("出版单位: %s\t\n",p->publisher); printf("出版时间: %s\t\n",p->pbtime);printf("分类号: %s\t\n",p->classfy);printf("价格: %.2f\t\n",p->price);}if(p->next==NULL){printf("\n查询完毕!\n");}}}return;}/*浏览操作*/void Print_Book_Doc(struct books_list * head) {struct books_list * p;if(head==NULL || head->next==NULL) /*判断数据库是否为空*/{printf("\n ━━━━没有图书记录! ━━━━\n\n");return;}p=head;printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━┳━━━━┓\n");printf("┃登录号┃书名┃作者┃出版单位┃出版时间┃分类号┃价格┃\n");printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━╋━━━━┫\n");/*指针从头节点开始移动,遍历至尾结点,依次输出图书信息*/while(p->next!= NULL){p=p->next;printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s┃%-12.12s┃%-6.6s┃%.2f ┃\n",p->loginnum,p->bookname,p->author,p->publisher,p->pbtime,p->classfy,p->pric e); /*循环输出表格*/}printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━┻━━━━┛\n");printf("\n");}/*删除操作*/void DeleteDoc(struct books_list * head){struct books_list *s,*p; /*s为中间变量,p为遍历时使用的指针*/ char temp[20];int panduan; /*此变量用于判断是否找到了书目*/panduan=0;p=s=head;printf(" [请输入您要删除的书名]:");scanf("%s",temp);/*遍历到尾结点*/while(p!= NULL){if(strcmp(p->bookname,temp)==0){panduan++;break;}p=p->next;}if(panduan==1){for(;s->next!=p;) /*找到所需删除卡号结点的上一个结点*/{s=s->next;}s->next=p->next; /*将后一节点地址赋值给前一节点的指针域*/free(p);printf("\n ━━━━删除成功! ━━━━\n"); }else /*未找到相应书目*/{printf(" 您输入的书目不存在,请确认后输入!\n"); }return;}int main(){struct books_list * head;char choice;head=NULL;for(;;) /*实现反复输入选择*/{printf(" ┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf(" ┃┃ tony 图书馆管理系统┃┃\n"); printf(" ┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf(" ┃ [1]图书信息录入┃\n"); printf(" ┃┃\n"); printf(" ┃ [2]图书信息浏览┃\n"); printf(" ┃┃\n"); printf(" ┃ [3]图书信息查询┃\n"); printf(" ┃┃\n"); printf(" ┃ [4]图书信息删除┃\n"); printf(" ┃┃\n"); printf(" ┃ [5]退出系统┃\n"); printf(" ┃┃\n"); printf(" ┃┃\n"); printf(" ┗━━━━━━━━━━━━━━━━━━━━━━━┛\n"); printf(" 请选择:");fflush(stdin);scanf("%c",&choice);if(choice=='1'){if(head==NULL){head=Create_Books_Doc(); }InsertDoc(head);}else if(choice=='2'){Print_Book_Doc(head);}else if(choice=='3'){search_book(head);}else if(choice=='4'){DeleteDoc(head);}else if(choice=='5'){printf("\n");printf(" ━━━━━━━━感谢使用图书管理系统━━━━━━━━\n");break;}else{printf(" ━━━━输入错误,请重新输入!━━━━\n");}}return 0;}。

C语言大作业之图书管理系统的实现详程

C语言大作业之图书管理系统的实现详程

C语⾔⼤作业之图书管理系统的实现详程⽬录主要内容概要设计项⽬源码结构体登录界⾯函数选择界⾯函数操作界⾯函数添加函数查找函数删除函数借书管理函数信息储存函数还书函数修改函数添加借书函数查找借书函数借书管理函数主函数总结序时间在流去,我们在长⼤。

嗨,这⾥是狐狸~~今天是2022年的⼀⽉四⽇了,元旦⼩长假也过去了,新年新⽓象,新年新⽬标,我们要向前看,不要执意过去了,感谢过去,把握现在,展望未来,这是我们现在应该做的。

好了,废话不多说,今天我们分享⼀个系统,确实也有许久没有分享过系统了,今天就给⼤家详细讲⼀下这个图书管理系统吧。

主要内容开发⼀个图书信息管理系统,图书信息包括:图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据⾃⼰情况进⾏扩充,⽐如是否借出、库存量等)。

使之能提供以下基本功能:(1)图书信息录⼊功能(图书信息⽤⽂件保存)--输⼊(2)图书信息浏览功能--输出(3)查询功能(⾄少⼀种查询⽅式)、排序功能(⾄少⼀种排序⽅式):(4)图书信息的删除与修改扩展功能:可以按照⾃⼰的程度进⾏扩展。

⽐如(1)简单的权限处理(2)报表打印功能(3)甚⾄根据⾃⼰情况,可以加上学⽣信息,并扩充为图书借阅系统。

(4)模糊查询(5)综合查询(6)统计功能⽐如统计处某⼀类别的图书信息或筛选出⼩于指定数量库存的图书信息等等。

概要设计1 图书录⼊可以录⼊图书名,作者,出版社,出版⽇期,价格!录⼊图书编号时函数就会判断此编号是否存在,若存在不能成功录⼊!2 图书浏览可以浏览全部图书!3 图书查询提供按图书编号模糊查询,按图书名关键字查询,按图书编号精确查询,按图书名精确查询!模糊查询和关键字查询事通过⽐价字符串的相似度⽽实现的!4 修改删除图书可以通过图书查询来查询操作的图书编号,通过编号操作!函数会提⽰⽤户是否调⽤图书查询来找到⾃⼰想要操作的图书的编号。

如果某⼀本图书已经被借阅那么⽤户就不能删除该图书!5 借阅图书通过学号和图书编号进⾏借阅!如果该学号是第⼀次借阅那么会提⽰⽤户输⼊⾃⼰的姓名,并存⼊student.txt,⽅便以后借阅与归还!6 归还图书先提供学号,然后程序会输出该学号借阅的所有图书,然后再通过编号归还!7 借阅查询可查询某个学⽣已借但未归还的图书!项⽬源码先建⽴结构体,定义结构体成员123456789101112131415161718192021222324252627282930typedef struct book/*图书结构体*/{char num[10]; /*书号*/char name[10]; /*书名*/char auth[10]; /*作者*/int count;int sum;}Book;typedef struct borrow/*借书结构体*/{char id[20];char user[20];char book[20];char bookid[20];struct borrow *next;}BBnode,*BBlink;struct user{char num[10];/* 学号 */char pass[15];char name[15];char sex[10];};typedef struct unode{struct user data;struct unode *next;}Unode,*Ulink;Unode *os;登录界⾯函数123456789101112131415161718int login(Ulink l){ /*****************登陆窗⼝初始化****************************/while(!flag){char User_id[10],password[10],tmp;int i=0;User_id[0]='\0';23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80textcolor(YELLOW);cputs("ESC = EXIT");textcolor(WHITE);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("Login now please input the User__ID and Password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(User_id[0]=='\0'){gotoxy(31,11);textcolor(YELLOW);textbackground(5);cputs("User__ID:");gotoxy(31,13);cputs("Password:");textbackground(179);textcolor(WHITE);gotoxy(28,7);cputs("please input the User__ID!");textbackground(179);textcolor(YELLOW);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))) {textcolor(YELLOW);textbackground(5);putch(tmp);User_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return0;}}User_id[i]='\0';}/**********************密码过滤****************************/while(password[0]=='\0'){gotoxy(28,7);textbackground(179);textcolor(WHITE);cputs(" input the password now ");textbackground(179);textcolor(YELLOW);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return0;858687888990919293949596979899100101102103104105106107108109110111112password[i]=tmp;i++;tmp=getch(); if(tmp==27) {flg=27;return 0;}}password[i]='\0';}/*************把账号和密码进⾏对⽐验证**************/if(!strcmp(User_id,"admin")&&!strcmp(password,"admin")){ return 2; }if(cmps(l,User_id,password)){return 1;}}}选择界⾯函数1234567891011121314151617181920212223void choose(){while(1){ textbackground(179);clrscr();gotoxy(33,2);textcolor(WHITE);cputs("Administrastor");textcolor(YELLOW);box(1,1,80,24);h_line(2,3,78);gotoxy(3,6);cputs(">>>er Management----------------------------<<<");gotoxy(3,10);cputs(">>>-------------------------2.Book Management----------------------------<<<"); gotoxy(3,14);cputs(">>>-------------------------3.Borrow Books-------------------------------<<<");gotoxy(30,22);textcolor(RED);cputs("Please Select");28293031323334353637383940414243444546474849505152if(flg=='3')borrow();if(flg==27){ flg=-1;return;}} }void admin(){while(1){choose(); if(flg=='1') bookss();if(flg=='2')users();if(flg=='3')borrow();if(flg==27){return;}}}操作界⾯函数1234567891011121314151617181920212223242526void user(Ulink h){int flag;BBlink l,p,r;/* 连表 */FILE *fp; /* ⽂件指针 */int count=0;l=(BBnode*)malloc(sizeof(BBnode));l->next=NULL;r=l;fp=fopen(bfile,"rb");if(fp==NULL){ fp=fopen(bfile,"wb");}while(!feof(fp)){ p=(BBnode*)malloc(sizeof(BBnode)); if(fread(p,sizeof(BBnode),1,fp)) /* 将⽂件的内容放⼊接点中 */ {p->next=NULL;r->next=p; r=p; /* 将该接点挂⼊连中 */ count++; }313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778textcolor(YELLOW);box(1,1,80,24);h_line(2,3,78); gotoxy(3,2); textcolor(RED);cputs("A.");textcolor(BLUE);cputs("my message "); textcolor(RED); cputs("B."); textcolor(BLUE);cputs("modyfy my message ");textcolor(RED); cputs("C."); textcolor(BLUE); cputs("my borrow ");textcolor(RED);cputs("D."); textcolor(BLUE); cputs("search book"); textcolor(YELLOW);gotoxy(50,50);flag=getch();switch(flag) { case 'a': show(os);break; /*************添加⽤户**********/ case 'b':Modify_user(h);Save(h); break;/*************删除⽤户**********/ case 'c': Myborrow(); break;case 'd':usersearch();break; case 27: return; } }}添加函数图书的添加,包括⽤户添加以及管理员添加16 7 8 9 1011 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63void add(blink l){Bnode *p,*r,*s;char num[10];r=l;s=l->next;while(r->next!=NULL)r=r->next;textcolor(RED);gotoxy(25,4);cputs("INPUT THE MESSAGE ABOUT BOOK"); gotoxy(31,10);textcolor(YELLOW);cputs("Book ID:");scanf("%s",num);p=(Bnode *)malloc(sizeof(Bnode));while(s){if(strcmp(s->data.num,num)==0){textcolor(WHITE);gotoxy(25,15);cputs("This ID:");printf("'%s'",num);cputs("is exist!");gotoxy(25,22);cputs("please Press any key to continue..."); gotoxy(255,252);getch();return;}s=s->next;}strcpy(p->data.num,num);gotoxy(31,12);textcolor(YELLOW);cputs("Input Book name:");scanf("%s",p->);gotoxy(31,14);cputs("input your Book auth:");scanf("%s",p->data.auth);gotoxy(31,16);cputs("input your Book count:");scanf("%d",&p->data.count);bookcount=p->data.count+bookcount;p->data.sum=0;p->next=NULL;r->next=p;r=p;gotoxy(30,22);textcolor(RED);cputs("Add Book Success ");getch();textcolor(YELLOW);}/*******管理员添加⽤户*******/void Add(Ulink l){Unode *p,*r,*s;char num[10];r=l;s=l->next;while(r->next!=NULL)r=r->next;6869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109textcolor(YELLOW);cputs("User ID:");scanf("%s",num);p=(Unode *)malloc(sizeof(Unode)); while(s){if(strcmp(s->data.num,num)==0){ gotoxy(25,15); cputs("This ID:"); printf("'%s'",num);cputs("is exist!");gotoxy(25,22); textcolor(RED); cputs("please Press any key to continue..."); gotoxy(255,252);getch();return;} s=s->next;}strcpy(p->data.num,num);gotoxy(31,12);textcolor(YELLOW);cputs("Input Password:");scanf("%s",p->data.pass);gotoxy(31,14);cputs("input your name:");scanf("%s",p->);gotoxy(31,16);cputs("input the sex:");scanf("%s",p->data.sex);p->next=NULL;r->next=p;r=p;gotoxy(30,22);cputs("Add User Success ");usercount++;getch();textcolor(YELLOW);}查找函数⽤户查找以及管理员查找123456712 13 14 15 16 17 18 19 20 21 22 23 2425 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69/*******管理员查找图书*******/void qur(blink l){int sel;char findmess[20];Bnode *p;if(!l->next){gotoxy(30,4);textcolor(WHITE);cputs("Not Find Bookdata");getch();return;}textcolor(RED);gotoxy(25,4);cputs("Please Select Search Type !"); gotoxy(10,8);textcolor(WHITE);cputs("1.Search by ID");gotoxy(10,10);cputs("2.Search by Name");gotoxy(10,12);cputs("Please Select 1 or 2:");scanf("%d",&sel);if(sel==1){gotoxy(36,8);textcolor(YELLOW);cputs("Input the search ID:");scanf("%s",findmess);p=locate(l,findmess,"num");if(p){gotoxy(36,12);textcolor(WHITE);cputs("Book ID:");printf("%s",p->data.num);gotoxy(36,14);textcolor(WHITE);cputs("Book Name:");printf("%s",p->);gotoxy(36,16);textcolor(WHITE);cputs("Book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(WHITE);cputs("Book count:");printf("%d",p->data.count);getch();textcolor(YELLOW);gotoxy(30,21);74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 textcolor(RED);cputs("Not finde ");getch();}}else if(sel==2) /* 姓名 */{gotoxy(36,8);textcolor(YELLOW);cputs("Input the search name:");scanf("%s",findmess);p=locate(l,findmess,"name");if(p){gotoxy(36,12);textcolor(WHITE);cputs("Book ID:");printf("%s",p->data.num);gotoxy(36,14);textcolor(WHITE);cputs("Book Name:");printf("%s",p->);gotoxy(36,16);textcolor(WHITE);cputs("Book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(WHITE);cputs("Book count:");printf("%d",p->data.count);getch();textcolor(YELLOW);}else{textcolor(RED);gotoxy(30,22);cputs("Not finde ");}}else{textcolor(RED);gotoxy(30,22);cputs("Error !!");getch();}}/*******⽤户查找图书*******/void usersearch(){int sel;char findmess[20];Bnode *p;blink l;/* 连表 */FILE*fp; /* ⽂件指针 */int count=0;Bnode *P,*r;l=(Bnode*)malloc(sizeof(Bnode));l->next=NULL;r=l;fp=fopen(file,"rb");if(fp==NULL){fp=fopen(file,"wb");}while(!feof(fp)){P=(Bnode*)malloc(sizeof(Bnode));if(fread(P,sizeof(Bnode),1,fp)) /* 将⽂件的内容放⼊接点中 */ {P->next=NULL;bookcount=bookcount+P->data.count;booksum=booksum+P->data.sum;136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 r->next=P;r=P; /* 将该接点挂⼊连中 */count++;}}fclose(fp); /* 关闭⽂件 */if(!l->next){gotoxy(30,4);textcolor(WHITE);cputs("Not Find Bookdata");getch();return;}textcolor(RED);gotoxy(25,4);cputs("Please Select Delete Type !"); gotoxy(10,8);textcolor(WHITE);cputs("1.Search by ID");gotoxy(10,10);cputs("2.Search by Name");gotoxy(10,12);cputs("Please Select 1 or 2:");scanf("%d",&sel);if(sel==1){gotoxy(36,8);textcolor(YELLOW);cputs("Input the search ID:");scanf("%s",findmess);p=locate(l,findmess,"num");if(p){gotoxy(36,12);textcolor(WHITE);cputs("Book ID:");printf("%s",p->data.num);gotoxy(36,14);textcolor(WHITE);cputs("Book Name:");printf("%s",p->);gotoxy(36,16);textcolor(WHITE);cputs("Book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(WHITE);cputs("Book count:");printf("%d",p->data.count-p->data.sum); getch();textcolor(YELLOW);}else{gotoxy(30,22);textcolor(RED);cputs("Not finde ");getch();}}else if(sel==2){gotoxy(36,8);textcolor(YELLOW);cputs("Input the search name:");scanf("%s",findmess);p=locate(l,findmess,"name");if(p){gotoxy(36,12);textcolor(WHITE);cputs("Book ID:");printf("%s",p->data.num);198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 gotoxy(36,14);textcolor(WHITE);cputs("Book Name:");printf("%s",p->);gotoxy(36,16);textcolor(WHITE);cputs("Book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(WHITE);cputs("Book count:");printf("%d",(p->data.count-p->data.sum)); getch();textcolor(YELLOW);}else{textcolor(RED);gotoxy(30,22);cputs("Not finde ");}}else{textcolor(RED);gotoxy(30,22);cputs("Error !!");getch();}}/*******图书查找*******/int cmpbook(blink l,char id[],char na[]){char findm[20];Bnode *p;if(!l->next){gotoxy(25,4);textcolor(RED);cputs("Not Find Book");getch();return0;}strcpy(findm,id);p=locate(l,findm,"num");if(p){strcpy(findm,na);p=locate(l,findm,"name");if(p){return1;}else{textcolor(RED);gotoxy(30,22);cputs("Book name is NULL ");getch();return0;}}else{gotoxy(30,22);textcolor(RED);cputs("Book id is NULL ");getch();return0;}260261262263264265266267268269270271272273274275276277278279280281282283284285286287}删除函数图书的删除12345678 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25void del(blink l){int sel;Bnode *p,*r;char findmess[20];if(!l->next){gotoxy(25,4);textcolor(RED);cputs("=====>not thing could delete!\n"); getch();return;}textcolor(RED);gotoxy(25,4);puts("Please Select Delete Type !");gotoxy(10,8);textcolor(WHITE);cputs("1.Delete by Book ID");26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 gotoxy(10,10);cputs("2.Delete by Book Name");gotoxy(10,12);cputs("Please Select 1 or 2:");scanf("%d",&sel);if(sel==1){gotoxy(36,8);textcolor(YELLOW);cputs("Input the delete ID:");scanf("%s",findmess);p=locate(l,findmess,"num");if(p){bookcount=bookcount-p->data.count; r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);gotoxy(30,22);textcolor(RED);cputs("Delete success!\n");textcolor(YELLOW);}else{textcolor(RED);gotoxy(30,22);cputs("Error !!");}}else if(sel==2){gotoxy(36,8);textcolor(YELLOW);cputs("Input the delete name:");scanf("%s",findmess);p=locate(l,findmess,"name");if(p){r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);gotoxy(30,22);textcolor(RED);cputs("Delete success!\n");bookcount--;textcolor(YELLOW);}else{gotoxy(25,18);cputs("Not find!!");}}else{textcolor(RED);gotoxy(30,22);cputs("Error !!");}getch();textcolor(YELLOW);}借书管理函数1234567 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56void borrow(){while(1){int flag;BBlink l,p,r;/* 连表 */FILE*fp; /* ⽂件指针 */int count=0;l=(BBnode*)malloc(sizeof(BBnode));l->next=NULL;r=l;fp=fopen(bfile,"rb");if(fp==NULL){fp=fopen(bfile,"wb");}while(!feof(fp)){p=(BBnode*)malloc(sizeof(BBnode));if(fread(p,sizeof(BBnode),1,fp)) /* 将⽂件的内容放⼊接点中 */ {p->next=NULL;r->next=p;r=p; /* 将该接点挂⼊连中 */count++;}borrowcount=count;}while(1){textbackground(179);clrscr();textcolor(YELLOW);box(1,1,80,24);h_line(2,3,78);gotoxy(3,2);textcolor(RED);cputs("B");textcolor(BLUE);cputs("orrow book ");textcolor(RED);cputs("R");textcolor(BLUE);cputs("eturn book ");textcolor(RED);cputs("S");textcolor(BLUE);cputs("earch borrow ");textcolor(YELLOW);printf("count: (borrow=%d)",borrowcount);textcolor(RED);gotoxy(50,50);flag=getch();switch(flag){case'b':Add_borrow(l);break; /*************添加⽤户**********/case'r':57585960616263646566676869707172Del_borrow(l);Save_borrow(l);break; case 's': Qur_borrow(l); break;case 27:return;}} }}信息储存函数图书信息的储存123456789101112131415161718192021222324252627282930313233343536*******借书信息保存*******/void Save_borrow(BBlink l){FILE* fp;BBnode *p; int flag=1,count=0; fp=fopen(bfile,"wb"); if(fp==NULL) {gotoxy(35,12);textcolor(RED); cputs("open error!"); exit(1); }p=l->next;while(p){ if(fwrite(p,sizeof(BBnode),1,fp)==1) {p=p->next;count++;} else {flag=0;break;}}if(flag){textcolor(RED);gotoxy(30,24); /*** printf("save success.(saved%d.)",count);**调试的时候⽤的*/}fclose(fp);}还书函数123456789101112 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/* 还书的操作 */void Del_borrow(BBlink l){int sel;BBnode *p,*r;Bnode *L;char findmess[20];FILE*fp; /* ⽂件指针 */Bnode *P,*R,*Q;L=(Bnode*)malloc(sizeof(Bnode));L->next=NULL;R=L;fp=fopen(file,"rb");if(fp==NULL){fp=fopen(file,"wb");}while(!feof(fp)){P=(Bnode*)malloc(sizeof(Bnode));if(fread(P,sizeof(Bnode),1,fp)) /* 将⽂件的内容放⼊接点中 */ {P->next=NULL;R->next=P;R=P; /* 将该接点挂⼊连中 */}}fclose(fp); /* 关闭⽂件 */if(!l->next){gotoxy(30,4);textcolor(RED);cputs("not Book could Return!\n");getch();return;}textcolor(RED);gotoxy(25,4);puts("Please Select Return Type !");gotoxy(10,8);textcolor(WHITE);cputs("1.Return by Borrow ID");gotoxy(10,10);cputs("2.Return by book name");gotoxy(10,12);cputs("Please Select 1 or 2:");scanf("%d",&sel);if(sel==1){gotoxy(36,8);textcolor(YELLOW);cputs("Input the Borrow ID:");57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 scanf("%s",findmess);p=Locate_borrow(l,findmess,"num"); if(p){Q=locate(L,findmess,"num");if(Q){Q->data.sum=Q->data.sum-1; save(L);}r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);gotoxy(30,22);textcolor(RED);cputs("Return success!\n");borrowcount--;getch();textcolor(YELLOW);}else{gotoxy(30,22);textcolor(RED);cputs("Note find !!");getch();}}else if(sel==2){gotoxy(36,8);textcolor(YELLOW);cputs("Input the Book name:");scanf("%s",findmess);p=Locate_borrow(l,findmess,"book"); if(p){Q=locate(L,findmess,"name"); if(Q){Q->data.sum=Q->data.sum-1; save(L);}r=l;while(r->next!=p)r=r->next;r->next=p->next;free(p);gotoxy(30,22);textcolor(RED);cputs("Borrow success!\n");borrowcount--;getch();textcolor(YELLOW);}else{gotoxy(30,18);textcolor(RED);cputs("Not find!!");getch();}}else{gotoxy(30,22);textcolor(RED);cputs("Not finde !!");119120121122123124125126127128129130131132getch();}textcolor(YELLOW);}修改函数也分为⽤户和管理员两种情况123456789101112131415161718192021222324252627282930313233343536373839/* ****⽤于管理员修改⽤户资料 ***/void Modify(Ulink l){Unode *p; char findmess[20]; if(!l->next) {gotoxy(30,4);textcolor(RED);cputs("not thing could modify!"); getch(); return;}gotoxy(30,4);textcolor(RED); cputs("Modify User Message"); gotoxy(25,8); textcolor(YELLOW);cputs("input the User Id:");scanf("%s",findmess); p=Locate(l,findmess,"num"); if(p) {textcolor(YELLOW);gotoxy(25,10); printf("Inpute The New ID(old:%s):",p->data.num); scanf("%s",p->data.num); gotoxy(25,12);printf("Input The New Password(old:%s):",p->data.pass); scanf("%s",p->data.pass);gotoxy(25,14); printf("Input The New Name(old:%s):",p->); scanf("%s",p->);gotoxy(25,16);printf("Input The New Sex(old:%s):",p->data.sex); scanf("%s",p->data.sex); gotoxy(30,20);40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 textcolor(RED);cputs("Modify Success ");getch();textcolor(YELLOW);}else{gotoxy(30,16);textcolor(RED);cputs("Not Finde ");getch();}}/****供⽤户修改⽤户⾃⼰资料 */void Modify_user(Ulink l){Unode *p;char findmess[20];if(!l->next){gotoxy(30,4);textcolor(RED);cputs("not thing could modify!");getch();return;}gotoxy(30,4);textcolor(RED);cputs("Modify User Message");gotoxy(33,8);textcolor(YELLOW);strcpy(findmess,os->data.num);printf("your id:%s",findmess);p=Locate(l,findmess,"num");if(p){textcolor(YELLOW);gotoxy(24,10);printf("Input The New Password(old:%s):",p->data.pass); scanf("%s",p->data.pass);gotoxy(24,12);printf("Input The New Name(old:%s):",p->);scanf("%s",p->);gotoxy(24,14);printf("Input The New Sex(old:%s):",p->data.sex);scanf("%s",p->data.sex);gotoxy(31,18);textcolor(RED);cputs("Modify Success ");getch();textcolor(YELLOW);}else{gotoxy(30,16);textcolor(RED);cputs("Not Finde ");getch();}}添加借书函数1234567891011 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56/*******添加借书*******/void Add_borrow(BBlink l){Ulink H;/* 连表 */FILE*Fp; /* ⽂件指针 */Unode *Q,*T;blink L;/* 连表 */FILE*FP; /* ⽂件指针 */int ttl;Bnode *P,*R;char bookid[20];char bookname[20];char userid[20];BBnode *p,*r,*s;char num[10];r=l;s=l->next;while(r->next!=NULL)r=r->next;L=(Bnode*)malloc(sizeof(Bnode));L->next=NULL;R=L;FP=fopen(file,"rb");if(FP==NULL){FP=fopen(file,"wb");}while(!feof(FP)){P=(Bnode*)malloc(sizeof(Bnode));if(fread(P,sizeof(Bnode),1,FP)) /* 将⽂件的内容放⼊接点中 */ {P->next=NULL;bookcount=bookcount+P->data.count;R->next=P;R=P; /* 将该接点挂⼊连中 */}}fclose(FP); /* 关闭⽂件 */H=(Unode*)malloc(sizeof(Unode));H->next=NULL;T=H;Fp=fopen(ufile,"rb");if(Fp==NULL){Fp=fopen(ufile,"wb");}while(!feof(Fp)){Q=(Unode*)malloc(sizeof(Unode));60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 T->next=Q;T=Q; /* 将该接点挂⼊连中 */}}fclose(Fp);textcolor(RED);gotoxy(25,4);cputs("Please input thease message");gotoxy(30,10);textcolor(YELLOW);cputs("Input Borrow ID:");scanf("%d",&ttl);itoa(ttl,num,10) ;p=(BBnode *)malloc(sizeof(BBnode));while(s){if(strcmp(s->id,num)==0){gotoxy(30,15);cputs("Borrow ID:");printf("'%s'",num);cputs("is exist!");gotoxy(26,22);textcolor(RED);cputs("please Press any key to continue...");gotoxy(255,252);getch();return;}s=s->next;}strcpy(p->id,num);gotoxy(31,12);textcolor(YELLOW);cputs("Input book id:");scanf("%s",bookid);gotoxy(31,14);textcolor(YELLOW);cputs("Input book name:");scanf("%s",bookname);/***************************************图书判断在否***************************************/ if(cmpbook(L,bookid,bookname)){strcpy(p->bookid,bookid);strcpy(p->book,bookname);gotoxy(31,16);cputs("input your ID:");scanf("%s",userid); /**************************************⽤户判断在否********************************/if(cmpuser(H,userid)){strcpy(p->user,userid);p->next=NULL;r->next=p;r=p;if(changeb(L,bookid)){gotoxy(30,22);cputs("Borrow Success ");Save_borrow(l);borrowcount++;getch();}}}textcolor(YELLOW);}。

C语言课程设计-图书信息管理系统设计

C语言课程设计-图书信息管理系统设计

图书信息管理系统设计一、【要求】图书信息包括:登录号、书名、作者名、分类号、出版单位、出版时间、价格等。

设计一图书信息管理系统,使之能提供以下功能:(1)系统以菜单方式工作(2)图书信息录入功能(3)图书信息浏览功能(4)图书信息查询功能(5)图书信息的删除与修改功能二、【各功能模块】1、菜单模块《1》、主函数:建立menu( )void main(){menu();}void menu(){int a;do{printf(” ******赵毅******\n”);printf("\n”);printf(”******中国地质大学******\n”);printf("\n");printf(”\n\n\n\n\n\t\t\t\t图书信息管理系统\t\t\t\t\n”);printf("\t\t********************************************\n");printf(”\t\t\t1 ———--—----—-—-——图书信息录入\n”);printf("\t\t\t2 -—-—-———-—-———-—图书信息浏览\n”);printf(”\t\t\t3 -——-—-——-——-——--图书信息查询\n");printf("\t\t\t4 ——--—-—--——-———-图书信息删除\n”);printf("\t\t\t5 ——————-—-—--—-——图书信息修改\n”);printf(”\t\t\t6 --——-———--——--——图书信息追加\n”);printf(”\t\t\t0 ——--—---—--——---退出图书信息系统\n”);printf("\t\t********************************************\n”);printf(”\t\tplease choose:”);scanf("%d",&a);switch(a){case 1:input();break;case 2:list();break;case 3:search();break;case 4:del();break;case 5:revise();break;case 6:append();break;case 0:exit(0);default:printf(”\n序号不对\n”);}}while(a!=0);}【定义图书信息结构体】#include<stdio。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

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");}主函数提供人机交互界面,让操作者选择所需的操作项目,并有退出选项。

源代码:void xinshu(){int i;FILE *fp;if((fp=fopen("library.txt","w"))==NULL){printf("打开文件失败!\n");exit(0);}printf("请输入要录入的新书的编号:");scanf("%d",&s[count].number);for(i=0;i<count;i++){if(s[i].number==s[count].number){printf("编号已存在,请重新输入:");scanf("%d",&s[count].number);}}printf("请输入图书名称:");scanf("%s",&s[count].name);printf("请输入图书作者:");scanf("%s",&s[count].author);printf("请输入图书数量:");scanf("%d",&s[count].shuliang);count++;fclose(fp);printf("录入成功!\n");printf("\n");printf("\n");printf("\n");}新书录入模块实现了新书的编号、书名、作者、数量的录入,并设计有输入错误时的提示。

源代码:void jieshu(){int b,i,shu;printf("请输入要借书的编号:");scanf("%d",&b);for(i=0;i<=count;i++){if(s[i].number==b){printf("您要借的书是:\n");printf("\t编号\t书名\t作者\t数量\n");printf("\t%d\t%s\t%s\t%d\n",s[i].number,s[i].name,s[i].a uthor,s[i].shuliang);printf("确认后请输入要借书的数量:");scanf("%d",&shu);if((s[i].shuliang-shu)>=0){printf("借书成功!");s[i].shuliang=s[i].shuliang-shu;}else{printf("抱歉,图书数量不够> < 请重新输入:");scanf("%d",&shu);}}printf("\n");printf("\n");printf("\n");}}借书模块实现了对指定图书的借出,并在借出时程序将图书数量自行减去借出数量,在所借图书数量超过现有数量时给出提示。

源代码:void huanshu(){int i,d,e;printf("请输入要还书的编号:");scanf("%d",&d);for(i=0;i<=count;i++){if(s[i].number==d){printf("请输入要还书的数量:");scanf("%d",&e);s[i].shuliang=s[i].shuliang+e;printf("还书成功!\n");break;}}if(i>count){printf("此图书不存在");}printf("\n");printf("\n");printf("\n");}还书模块实现简便的还书过程,并用count的变化来调整图书数量。

源代码:void chaxun(){int i,f;printf("请输入要查找图书的编号:");scanf("%d",&f);for(i=0;i<count;i++){if(s[i].number==f){printf("您要查询的图书是:\n");printf("\t编号\t书名\t作者\t数量\n");printf("\t%d\t%s\t%s\t%d\n",s[i].number,s[i].name,s[i].a uthor,s[i].shuliang);break;}}if(i>count){printf("此图书不存在\n");}printf("\n");printf("\n");printf("\n");}该模块实现对图书的查询功能,通过对图书编号的检索,给出该图书的对应信息,包括图书名称、作者、剩余数量。

三.数据文件名数据文件名为library.txt,用于新书录入的数据存储。

四.系统运行测试结果分析交互界面:新书录入:借书:当所借数量小于等于所存数量时,即显示结束成功。

当所借书数量超过图书总量,则给出提示,重新输入。

查询:从借书后的查询结果与新书录入时的数量相比较,可以看出已经减去所借出的图书数量。

还书:还回借出的两本书里的一本后,经查询可得数量得到相对应的减少。

退出:收获与体会:经过一学期的C语言程序设计的学习后,对于C语言有了初步的认识,并能开始写简单的程序,但是对于这个大作业还是烦恼了一阵子,由于程序会写的很长,调试过程也会比较困难,所以我们决定组队一起完成这个大程序,xxx负责主函数以及借书、新书模块以及函数的调试过程等,xxxx负责查询、还书模块以及设计报告的封面等,这个大程序占用了我们很多时间,调试过程中遇到了很多疑惑,也找过大神求助过,最后好不容易可以运行了,也是出现了好多小问题,就这样反反复复,最后的最后,得到成功的时候,我们都欢呼雀跃了,感觉到程序设计的神奇,看到自己写的程序可以实现这样的小功能就觉得非常自豪,当然,过程中也显示了我们的知识不扎实,才会如此辛苦,看来,学好C语言并不是一件容易的事,但是我们相信,只要有一次成功,就会有更多的成功。

我想,这就是我们学到的吧。

设计人员:xxx:设计报告封面,查询还书模块xxx:主函数,借书新书模块,程序运行调试全代码:#include<stdio.h>#include<stdlib.h>#include<string.h>struct BOOK{char name[20];char author[20];int number,shuliang;} s[10000];int count=0;void jieshu();void huanshu();void xujie();void xinshu();void chaxun();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");}void xinshu(){int i;FILE *fp;if((fp=fopen("library.txt","w"))==NULL) {printf("打开文件失败!\n");exit(0);}printf("请输入要录入的新书的编号:"); scanf("%d",&s[count].number);for(i=0;i<count;i++){if(s[i].number==s[count].number){printf("编号已存在,请重新输入:");scanf("%d",&s[count].number);}}printf("请输入图书名称:");scanf("%s",&s[count].name);printf("请输入图书作者:");scanf("%s",&s[count].author);printf("请输入图书数量:");scanf("%d",&s[count].shuliang);count++;fclose(fp);printf("录入成功!\n");printf("\n");printf("\n");printf("\n");}void huanshu(){int i,d,e;printf("请输入要还书的编号:");scanf("%d",&d);for(i=0;i<=count;i++){if(s[i].number==d){printf("请输入要还书的数量:");scanf("%d",&e);s[i].shuliang=s[i].shuliang+e;printf("还书成功!\n");break;}}if(i>count){printf("此图书不存在");}printf("\n");printf("\n");printf("\n");}void chaxun(){int i,f;printf("请输入要查找图书的编号:");scanf("%d",&f);for(i=0;i<count;i++){if(s[i].number==f){printf("您要查询的图书是:\n");printf("\t编号\t书名\t作者\t数量\n");printf("\t%d\t%s\t%s\t%d\n",s[i].number,s[i].name,s[i].a uthor,s[i].shuliang);break;}}if(i>count){printf("此图书不存在\n");}printf("\n");printf("\n");printf("\n");}void jieshu(){int b,i,shu;printf("请输入要借书的编号:");scanf("%d",&b);for(i=0;i<=count;i++){if(s[i].number==b){printf("您要借的书是:\n");printf("\t编号\t书名\t作者\t数量\n");printf("\t%d\t%s\t%s\t%d\n",s[i].number,s[i].name,s[i].a uthor,s[i].shuliang);printf("确认后请输入要借书的数量:");scanf("%d",&shu);if((s[i].shuliang-shu)>=0){printf("借书成功!");s[i].shuliang=s[i].shuliang-shu;}else{printf("抱歉,图书数量不够> < 请重新输入:");scanf("%d",&shu);}}printf("\n");printf("\n");printf("\n");}}。

相关文档
最新文档