C语言-图书管理系统教程文件

合集下载

C语言版图书管理系统

C语言版图书管理系统

图书管理系统班级:软件2班姓名:晁永兵学号:201116040220#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 booknum[10]; /*图书编号*/float price; /*价格*/char lendername[20]; /*借书人姓名*/ char lendersex[10]; /*借书人性别*/ char lendernum[20]; /*借书人学号*/struct books_list * next; /*链表的指针域*/};/*清屏函数*/void Clear(){system("cls");}/*保存数据至文件*/void save(struct books_list * head){struct books_list *p;FILE *fp;p=head;fp=fopen("f1.txt","w+");fprintf(fp,"%20s%20s%20s%20s%20s%20f%20s%20s%20s",p->bo oknum,p->bookname,p->author,p->publisher,p->pbtime,p->price,p->lendername,p->lendersex,p->lendernum);while(p->next!= NULL){p=p->next;fprintf(fp,"%20s%20s%20s%20s%20s%20f%20s%20s%20s",p->bo oknum,p->bookname,p->author,p->publisher,p->pbtime,p->price,p->lendername,p->lendersex,p->lendernum);}fclose(fp);printf("已将数据保存到f1.txt 文件\n");}/*插入*/struct books_list * InsertDoc(struct books_list * head,struct books_list * book){char a;struct books_list * ptr,* p;p=head;ptr=book;if(head==NULL){head=ptr;head->next=NULL;}else{while(p->next!=NULL)p=p->next;p->next=ptr;ptr->next=NULL;}printf("是否保存插入的图书信息?(Y/N)");getchar();scanf("%c",&a);if(a=='Y'||a=='y')save(head);elseprintf("\n未保存插入后数据!\n\n");return head;}/*新建链表头节点*/struct books_list * Create_Books_Doc(){struct books_list * head,*p;int size=sizeof(struct books_list);head=NULL;char flag='Y';while(flag=='Y'||flag=='y'){p=(struct books_list *)malloc(sizeof(struct books_list));/*开辟新空间,存入数据,添加进链表*/here0:printf("\n 请输入图书编号:");getchar();scanf("%s",p->booknum);printf("\n 请输入图书书名:");getchar();scanf("%s",p->bookname);printf("\n 请输入图书作者名:");getchar();scanf("%s",p->author);printf("\n 请输入图书出版社:");getchar();scanf("%s",p->publisher);printf("\n 请输入图书出版时间:");getchar();scanf("%s",p->pbtime);printf("\n 请输入图书价格:");getchar();if(scanf("%f",&p->price)!=1){printf("价格输入有误,请重新输入!");goto here0;}printf("\n 请输入借书人姓名:");getchar();scanf("%s",p->lendername);printf("\n 请输入借书人性别:");getchar();scanf("%s",p->lendersex);printf("\n 请输入借书人学号:");getchar();scanf("%s",p->lendernum);printf("\n");head=InsertDoc(head,p);printf(" ━━━━添加成功!━━━━");printf("\n 继续添加(输入‘Y’或‘y’继续,否则结束)?");getchar();scanf("%c",&flag);printf("\n");}return head;}/*按照图书号查询*/void search_book1(struct books_list *head){int a=0;struct books_list * p;char temp[20];p=head;if(head==NULL)printf(" ━━━━图书库为空!━━━━\n"); else{printf("请输入您要查找图书的编号: ");getchar();scanf("%s",temp);while(p!= NULL){if(strcmp(p->booknum,temp)==0){printf("\n图书已找到!\n");printf("\n");printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━━┳━━━━━┳━━━━━┳━━━━━━┓\n");printf("┃图书号┃书名┃作者┃出版单位┃出版时间┃价格┃借书人姓名┃借书人性别┃借书人学号┃\n");printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━━╋━━━━━╋━━━━━╋━━━━━━┫\n");printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s ┃%-12.12s┃%-8.2f┃%-10.11s┃%-10.10s┃%-12.12s┃\n",p->booknum,p->bookname,p->author,p->publisher,p->pbtime,p->price,p->lendername,p->lendersex,p->lendernum);printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━━┻━━━━━┻━━━━━┻━━━━━━┛\n");printf("\n");a++;}p=p->next;if(p==NULL&&a==0)printf("\n查询完毕,未找到所要查询的信息!\n");}}return;}/*按照图书名查询*/void search_book2(struct books_list *head){int a=0;struct books_list * p;char temp[20];p=head;if(head==NULL)printf(" ━━━━图书库为空!━━━━\n"); else{printf("请输入您要查找书本的名称: ");getchar();scanf("%s",temp);while(p!= NULL){if(strcmp(p->bookname,temp)==0){printf("\n图书已找到!\n");printf("\n");printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━━┳━━━━━┳━━━━━┳━━━━━━┓\n");printf("┃图书号┃书名┃作者┃出版单位┃出版时间┃价格┃借书人姓名┃借书人性别┃借书人学号┃\n");printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━━╋━━━━━╋━━━━━╋━━━━━━┫\n");printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s ┃%-12.12s┃%-8.2f┃%-10.11s┃%-10.10s┃%-12.12s┃\n",p->booknum,p->bookname,p->author,p->publisher,p->pbtime,p->price,p->lendername,p->lendersex,p->lendernum);printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━━┻━━━━━┻━━━━━┻━━━━━━┛\n");printf("\n");a++;}p=p->next;if(p==NULL&&a==0)printf("\n查询完毕,未找到所要查询的信息!\n");}}return;}/*按照图书作者查询*/void search_book3(struct books_list *head){int a=0;struct books_list * p;char temp[20];p=head;if(head==NULL)printf(" ━━━━图书库为空!━━━━\n"); else{printf("请输入您要查找图书的作者: ");getchar();scanf("%s",temp);while(p!= NULL){if(strcmp(p->author,temp)==0){printf("\n图书已找到!\n");printf("\n");printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━━┳━━━━━┳━━━━━┳━━━━━━┓\n");printf("┃图书号┃书名┃作者┃出版单位┃出版时间┃价格┃借书人姓名┃借书人性别┃借书人学号┃\n");printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━━╋━━━━━╋━━━━━╋━━━━━━┫\n");printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s ┃%-12.12s┃%-8.2f┃%-10.11s┃%-10.10s┃%-12.12s┃\n",p->booknum,p->bookname,p->author,p->publisher,p->pbtime,p->price,p->lendername,p->lendersex,p->lendernum);printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━━┻━━━━━┻━━━━━┻━━━━━━┛\n");printf("\n");a++;}p=p->next;if(p==NULL&&a==0)printf("\n查询完毕,未找到所要查询的信息!\n");}}return;}/*按照借书人姓名查询*/void search_book4(struct books_list *head){int a=0;struct books_list * p;char temp[20];p=head;if(head==NULL)printf(" ━━━━图书库为空!━━━━\n"); else{printf("请输入您要查找的图书借书人姓名: ");getchar();scanf("%s",temp);while(p!= NULL){if(strcmp(p->lendername,temp)==0){printf("\n图书已找到!\n");printf("\n");printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━━┳━━━━━┳━━━━━┳━━━━━━┓\n");printf("┃图书号┃书名┃作者┃出版单位┃出版时间┃价格┃借书人姓名┃借书人性别┃借书人学号┃\n");printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━━╋━━━━━╋━━━━━╋━━━━━━┫\n");printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s ┃%-12.12s┃%-8.2f┃%-10.11s┃%-10.10s┃%-12.12s┃\n",p->booknum,p->bookname,p->author,p->publisher,p->pbtime,p->price,p->lendername,p->lendersex,p->lendernum);printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━━┻━━━━━┻━━━━━┻━━━━━━┛\n");printf("\n");a++;}p=p->next;if(p==NULL&&a==0)printf("\n查询完毕,未找到所要查询的信息!\n");}}return;}/*按照借书人学号查询*/void search_book5(struct books_list *head){int a=0;struct books_list * p;char temp[20];p=head;if(head==NULL)printf(" ━━━━图书库为空!━━━━\n"); else{printf("请输入您要查找图书的借书人学号: ");getchar();scanf("%s",temp);while(p!= NULL){if(strcmp(p->lendernum,temp)==0){printf("\n图书已找到!\n");printf("\n");printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━━┳━━━━━┳━━━━━┳━━━━━━┓\n");printf("┃图书号┃书名┃作者┃出版单位┃出版时间┃价格┃借书人姓名┃借书人性别┃借书人学号┃\n");printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━━╋━━━━━╋━━━━━╋━━━━━━┫\n");printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s ┃%-12.12s┃%-8.2f┃%-10.11s┃%-10.10s┃%-12.12s┃\n",p->booknum,p->bookname,p->author,p->publisher,p->pbtime,p->price,p->lendername,p->lendersex,p->lendernum);printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━━┻━━━━━┻━━━━━┻━━━━━━┛\n");printf("\n");a++;}p=p->next;if(p==NULL&&a==0)printf("\n查询完毕,未找到所要查询的信息!\n");}}return;}/*删除操作*/struct books_list * DeleteDoc(struct books_list * head){struct books_list * ptr1,* ptr2;int a=0;char b;char temp[20];printf(" [请输入您要删除的图书书名]:");scanf("%s",temp);while(head!=NULL&&strcmp(head->bookname,temp)==0){ ptr2=head;head=head->next;free(ptr2);a=1;printf("已成功删除!");}if(head==NULL){printf("\n链表为空,无法删除!\n\n");return NULL;}ptr1=head;ptr2=head->next;while(ptr2!=NULL){if(strcmp(ptr2->bookname,temp)==0){ptr1->next=ptr2->next;free(ptr2);a=1;printf("已成功删除!");}elseptr1=ptr2;ptr2=ptr1->next;}if(ptr2==NULL&&a==0){printf("\n未找到要删除的数据!\n\n");goto here10;}printf("是否保存删除后的图书信息?(Y/N)"); getchar();scanf("%c",&b);if(b=='Y'||b=='y')save(head);elseprintf("\n未保存删除后数据!\n\n");here10:return head;}/*浏览*/void Print_Book_Doc(struct books_list * head){struct books_list * p1;if(head==NULL){printf("\n链表为空,无法输出!\n\n");return;}printf("┏━━━┳━━━━━┳━━━━━┳━━━━━┳━━━━━━┳━━━━┳━━━━━┳━━━━━┳━━━━━━┓\n");printf("┃图书号┃书名┃作者┃出版单位┃出版时间┃价格┃借书人姓名┃借书人性别┃借书人学号┃\n");printf("┣━━━╋━━━━━╋━━━━━╋━━━━━╋━━━━━━╋━━━━╋━━━━━╋━━━━━╋━━━━━━┫\n");for(p1=head;p1;p1=p1->next)printf("┃%-6.6s┃%-10.10s┃%-10.10s┃%-10.10s ┃%-12.12s┃%-8.2f┃%-10.11s┃%-10.10s┃%-12.12s┃\n",p1->booknum,p1->bookname,p1->author,p1->publisher,p1->pbti me,p1->price,p1->lendername,p1->lendersex,p1->lendernum);printf("┗━━━┻━━━━━┻━━━━━┻━━━━━┻━━━━━━┻━━━━┻━━━━━┻━━━━━┻━━━━━━┛\n");printf("\n");}/*读文件*/struct books_list * Read(){struct books_list *p1,*head=NULL,*tail;FILE * fp;if((fp=fopen("f1.txt","r"))==NULL){printf("File open error!\n");printf("此时文件中无图书信息,请管理员先输入图书信息并进行保存。

图书管理系统 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语言编写图书管理系统WORD文档bbszp

纯C语言编写图书管理系统WORD文档bbszp

《C语言程序设计》课程设计实验报告题目:图书管理系统专业:班级:姓名:成绩:指导教师:完成日期:年月日目录第一章系统功能模块结构图 (3)1.1 系统调用的函数 (3)1.2 图书管理系统模块 (3)1.3 管理系统数据流图……………………………………………… .41.4 系统主菜单 (5)1.5 图书查询 (5)1.6 借阅图书 (5)1.7 管理系统…………………………………………………… ..51.8 还书 (6)1.9 退出系统 (6)第二章图书管理系统的结构 (6)2.1 主函数流程图 (6)2.2 程序文件存储设计 (7)第三章图书管理系统测试 (7)3.1 实验结果 (7)第四章实验体会 (7)4.1 体会与总结 (7)参考文献 (8)附录: 源代码 (8)1系统功能模块结构图本图书管理系统由查阅图书(chabook),借阅图书(lenbook),系统管理(图书管理,借书卡管理),还书(huanbook)。

四个大的菜单模块组成,其总体结构图如下:图1图书管理系统总体结构图1.1系统调用的函数图2 系统调用函数表1.2图书管理系统功能模块说明:主菜单包括:查阅图书菜单,借阅图书,系统管理菜单,还书。

查阅图书菜单:包括按书名查找模块,返回。

系统管理菜单:包括图书管理,借书卡管理。

图书管理: 1.增加图书2.删除图书3.修改图书4.图书统计借书卡管理:1.申请新卡 2.删除卡号3.借书统计4.卡号统计1.3图书管理系统的数据流图图3 图书管理系统数据流图1.4 主菜单直接运行程序,将进入主菜单Main Menu 然后按0-4键进入选择。

1.5 图书查询功能的实现在主菜单中选择“1:<cha xun book>”进入图书查询模块,输入1按书名查找,输入0则返回主菜单,1.6 借阅图书功能的实现在主菜单中选择“2:<jie yu book>”,输入卡号与书名即可,否则将提示错误信息,按0键返回1.7管理系统在主菜单中选择“3:<guan li xi tong>”1.7.1 增加图书在管理系统中选择“1:<Add book>”,然后输入书籍的序号,书名、作者、与借阅状态,即可完成添加图书操作。

图书信息管理系统c语言程序设计流程图

图书信息管理系统c语言程序设计流程图

图书信息管理系统c语言程序设计流程图下载温馨提示:该文档是我店铺精心编制而成,希望大家下载以后,能够帮助大家解决实际的问题。

文档下载后可定制随意修改,请根据实际需要进行相应的调整和使用,谢谢!并且,本店铺为大家提供各种各样类型的实用资料,如教育随笔、日记赏析、句子摘抄、古诗大全、经典美文、话题作文、工作总结、词语解析、文案摘录、其他资料等等,如想了解不同资料格式和写法,敬请关注!Download tips: This document is carefully compiled by theeditor.I hope that after you download them,they can help yousolve practical problems. The document can be customized andmodified after downloading,please adjust and use it according toactual needs, thank you!In addition, our shop provides you with various types ofpractical materials,such as educational essays, diaryappreciation,sentence excerpts,ancient poems,classic articles,topic composition,work summary,word parsing,copy excerpts,other materials and so on,want to know different data formats andwriting methods,please pay attention!图书信息管理系统C语言程序设计流程图详解在计算机科学中,设计和开发一个图书信息管理系统是一个常见的实践项目。

c语言图书管理系统

c语言图书管理系统
rg.h.ah = 0;
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语言版
//以每个字符为匹配条件
void setSearch(char *sea
rch,Book_info *bk,const char or){
while(bk!=NULL){
int j=0,m=0;
printf(&quot;\n\n\t新图书名称:&quot;);
scanf(&quot;%s&quot;,&amp;bk-&gt;name);
printf(&quot;\n\t新作者:&quot;);
scanf(&quot;%s&quot;,&amp;bk-&gt;auth);
printf(&quot;\n\t新出版社:&quot;);
}
//去掉data[0]
char setData(char *data){
int number;
for(number = 1;number&lt;=30;number++){
data[number-1] = data[number];
}
return *data;
}
//设置检索方式
if(B-&gt;number&gt;max.max_number){
max.max_number = B-&gt;number; //保存最大的编号
}
B = B-&gt;next;
}
fclose(fp);
printf(&quot;\n ***********************************************************************&quot;);

c语言课程设计图书馆管理系统

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.多媒体资料:课件、教学视频、在线教程。

图书馆管理系统-C语言

图书馆管理系统-C语言

/********这是第十组的程序,这个程序包括管理员的部分和读者的部分,管理员有删除书本、增加书本、修改密码、查询书本;读者的有借书、还书*****************************/ /*********************************以及查询图书馆中的所有图书的信息、你借阅的书本;管理员的初始密码是1234,读者的初始密码是3456;****************************************//****************************************************************************** ******************************************************/#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<string.h>#include<time.h>/******************************************定义************************************/#define topborrow 2#define SIZE 10struct book /*定义书的类型*/{char bookname[40]; /*书本的名字*/char author[40]; /*书本的作者*/long int booknum; /*书本的索引号*/char type[50]; /*书本的类型*/char address[40]; /*书本的位置*/int price; /*书本的价格*/int tag; /*是否借出*/};/******************************函数的声明************************//****************************读者*******************************/void readerwelcome(); /*读者欢迎界面*/void readerpw(); /*读者的密码*/void reader(); /*读者的界面*/void search_books(); /*查询书本*/void modify_password();/*修改读者的密码*/void write_time(); /*记录借书的时间*/void write1_time(); /*还书时候判断是否超期*/void return_books(); /*还书*/void borrow_books(); /*借书*/void search_borbooks();/*****查询你借阅书本***********/void search_allbooks();/****查询图书馆中所有书本*****/void findauthor();/*通过作者来查询*/void findname(); /*通过书名来查询*/void findnum(); /*通过索引号查询*//************************管理员**************************/void read_allbook(); /*查询图书馆中的所有书本************/void managerpw(); /*管理员的密码*/void welcome_manger() ;/*进入管理员的界面*/void modify_pw(); /*修改密码*/void addbook(); /*增加书本*/void delbook(); /*删除书本*/void manager(); /*管理员的界面*//***********************进入的程序**********************/void menu(); /*菜单*/void welcome(); /*欢迎的界面*/void choice(); /*选择的菜单*/void stop();/******************************主函数*************************************/ /*************************************************************************/ void main(){int choice;char goon='y';welcome();while(goon=='y'){flushall();scanf("%d",&choice);switch(choice){case 1 :managerpw();/*读者的界面*/break;case 2 :readerpw();/*调用读者的界面*/break;case 3 :stop();/*退出*/break;}printf("\nWould you like to continue or exit ? <y/n>");goon=getch();putch(goon);if(goon=='y') /*是否继续循环*/welcome();}getch();return;}/***************************欢迎的界面***************************************/ void welcome(){system("cls"); /*清屏*/printf("\n*********************************************************************** ****\n");printf("\n**\n");printf("\n* Welcome to Putian University library *\n");printf("\n**\n");printf("\n*********************************************************************** ****\n");menu();return;}/*************************菜单栏********************************************/void menu(){printf("\n*********************************************************************** *****\n");printf("\n* 1.Manager *\n");printf("\n* 2.Reader *\n");printf("\n* 3.Exit *\n");printf("\n* Which menu would you want to choice?*\n");printf("\n* Please input number <1/2/3> : *\n");printf("\n*********************************************************************** *****\n");return;}/*******************************不想进入图书馆系统,退出************************/void stop(){system("cls"); /*clean screen*/printf("\n\t\t************************************************\n");printf("\n\t\t* Thank you for use! *\n");printf("\n\t\t* Welcome to use next time! *\n");printf("\n\t\t************************************************\n");getch();exit(0);return;}/*************************管理员*********************************************/ /**************************模块**********************************************//***************************管理员的界面************************************/void welcome_manger(){system("cls");printf("\n*********************************************************************** *********");printf("\n\t Welcome to use the manager systme! ");printf("\n*********************************************************************** *******\n");return;}void manager(){int choice;char answer='y';while(answer=='y'||answer=='Y'){system("cls"); /*清空屏幕*/printf("\n\t\t************************************************\n");printf("\n\t\t* 1.delete books. *\n");printf("\n\t\t* 2.add books. *\n");printf("\n\t\t* 3.modify password. *\n");printf("\n\t\t* 4.search all book. *\n");printf("\n\t\t* 5.back. *\n");printf("\n\t\t************************************************\n");printf("\n\t\tWhich menu would you want choice<1-4>");choice=getch();switch(choice){case '1' :delbook();break;case '2' :addbook();break;case '3':modify_pw();break;case '4':read_allbook();break;case '5' :welcome();break;}printf("\nWould you want to go to manager?<y/n>");answer=getch();putch(answer);if(answer=='y'||answer=='Y')continue;elsebreak;}return;}/*************************管理员输入密码*****************************************/void managerpw(){FILE *fp;int i;char pw[4],pw1[4];welcome_manger();while (1){printf("\n\t\t\tPlease input you four password:");for(i=0;i<4;i++){pw[i]=getch();putch('*');}fp=fopen("manager_pw.txt","r");for(i=0;i<4;i++)fscanf(fp,"%c ",&pw1[i]);fclose(fp);if(pw[0]==pw1[0]&&pw[1]==pw1[1]&&pw[2]==pw1[2]&&pw[3]==pw1[3])break;elseprintf("\n\t\t\tYour password is wrong!Please input again!\n");}manager();return;}/****************************修改管理员的密码*****************************************/void modify_pw(){FILE *fp;char pw[4],pw1[4],answer='y';int i;system("cls"); /*清空屏幕*/printf("************************************************************************* ******\n");printf(" Welcome to use modify password system! \n");printf("*************************************************************************while(1){printf("\n\t\tPlease input you want to change password: ");for(i=0;i<4;i++){pw[i]=getch();putch('*');}printf("\n\t\tPlease input you want to change password again: ");for(i=0;i<4;i++){pw1[i]=getch();putch('*');}if(pw[0]==pw1[0]&&pw[1]==pw1[1]&&pw[2]==pw1[2]&&pw[3]==pw1[3]){fp=fopen("manager_pw.txt","w");for(i=0;i<4;i++)fprintf(fp,"%c ",pw[i]);fclose(fp);printf("\n\t\tYou modify successful modify password!");getch();break;}else{printf("\n\t\tYou input two time password different\n\t\tWould you want to try again<y/n>");answer=getch();putch(answer);if(answer=='y'||answer=='Y')continue;elsebreak;}}return;}/************************************查看所有的书本****************************/void read_allbook(){int i;struct book bookinf[SIZE];fp=fopen("book_list.txt","rb");for(i=0;i<SIZE;i++)fread(&bookinf[i],sizeof(struct book),1,fp);fclose(fp);for(i=0;i<SIZE;i++){if(bookinf[i].price==0)break;else{printf("\nbook name:%s\nbook author:%s\nbook type:%s\nBook num:%ld\nbook price:%d\nbook address:%s",bookinf[i].bookname,bookinf[i].author,bookinf[i].type,bookinf[i].booknum,bookinf[i].price,booki nf[i].address);if(bookinf[i].tag==1)printf("\n\tThe book have been borrow.");if(i%4==0)getch();}}return;}/**************************************增加书本*********************************/void addbook(){FILE *fp1,*fp2;int i=0,j;char answer='y';long int booknum;struct book bookinf[SIZE];do{printf("\nBook Name:");gets(bookinf[i].bookname); /*书本的名字*/printf("\nBook Author:");gets(bookinf[i].author); /*书本的作者*/fflush(stdin); /*清空键盘缓存*/printf("\nBooknum:");scanf("%ld",&bookinf[i].booknum); /*书本的索引号*/fflush(stdin);printf("\nBook Type:");gets(bookinf[i].type); /*书本的类型*/printf("\nBook Price:"); /*书本的价格*/scanf("%d",&bookinf[i].price);fflush(stdin);printf("\nBook Address:");gets(bookinf[i].address); /*书本的位置*/printf("\nBooktag:");scanf("%ld",&bookinf[i].tag);fflush(stdin);printf("\nWould you want to add more:<y/n>");answer=getch();putch(answer);if(i>=10) /*书本只能放20本书*/{printf("\n\tIt is more than our library storage.");break;}i++;}while(answer=='y'||answer=='Y');if((fp2=fopen("book_list.txt","ab"))!= NULL ){for(j=0;j<i;j++)fwrite(&bookinf[j],sizeof(struct book),1,fp2);fclose(fp2);}else{printf("The file can be written.\n");}return;}/****************************************删除课本*******************************/void delbook(){FILE *fp,*fp1;int i,j;long int num;struct book bookinf[SIZE];system("cls"); /*清空屏幕*/fp=fopen("book_list.txt","rb");if((fp=fopen("book_list.txt","rb"))==NULL){printf("Can't open this file!!!");exit(0);}for(i=0;i<SIZE;i++){fread(&bookinf[i],sizeof(struct book),1,fp);if(bookinf[i].booknum==0)break;elseprintf("\nBook num:%ld\nBook author:%s\nBook name:%s ",bookinf[i].booknum,bookinf[i].author,bookinf[i].bookname);}fclose(fp);printf("\nWhich book number you want to delete :");scanf("%ld",&num);for(i=0;i<SIZE;i++){if(num==bookinf[i].booknum){if(bookinf[i].tag==1)printf("\nThe book have been borrow,Please when it return and delete.");else{for(j=i;j<SIZE;j++)/******************************/{ /*****将后面的书本往前面覆盖***/bookinf[j].booknum=bookinf[j+1].booknum;bookinf[j].tag=0;/******************************/bookinf[j].price=bookinf[j+1].price;strcpy(bookinf[j].bookname,bookinf[j+1].bookname);strcpy(bookinf[j].author,bookinf[j+1].author);strcpy(bookinf[j].type,bookinf[j+1].type);strcpy(bookinf[j].address,bookinf[j+1].address);}fp1=fopen("book_list.txt","wb");for(i=0;i<SIZE;i++)fwrite(&bookinf[i],sizeof(struct book),1,fp1);fclose(fp1);printf("\nYou delete successful!!!");}}}if(num!=bookinf[i].booknum){printf("\nOur library doesn't have this book.");}return;}/**********************************************读者*********************************************//**********************************************模块*********************************************//************************************读者进入的密码,密码是3456**********************************/void readerwelcome(){system("cls"); /*清空屏幕*/printf("\n*********************************************************************** *********");printf("\n\t Welcome to use the reader systme! ");printf("\n*********************************************************************** *******\n");return;}void readerpw(){FILE *fp;char pw[4],pw1[4];int i;readerwelcome();while (1){printf("\n\t\t\tPlease input you four password:");for(i=0;i<4;i++){pw[i]=getch();putch('*');}fp=fopen("reader_pw.txt","r");for(i=0;i<4;i++)fscanf(fp,"%c ",&pw1[i]);fclose(fp);if(pw[0]==pw1[0]&&pw[1]==pw1[1]&&pw[2]==pw1[2]&&pw[3]==pw1[3]) break;else{printf("\n\t\t\tYour password is wrong!Please input again!\n");continue;}}reader();return;}void reader(){int choice;char answer='y';while(1){system("cls"); /*清空屏幕*/printf("\n\t\t************************************************\n");printf("\n\t\t* 1.borrow books. *\n");printf("\n\t\t* 2.return books. *\n");printf("\n\t\t* 3.search all books. *\n");printf("\n\t\t* 4.search you have borrow. *\n");printf("\n\t\t* 5.modify password. *\n");printf("\n\t\t* 6.back. *\n");printf("\n\t\t* 7.exit. *\n");printf("\n\t\t************************************************\n");printf("\n\t\tWhich menu would you want choice<1-4>");scanf("%d",&choice);switch(choice){case 1 :borrow_books();break;case 2 :return_books();break;case 3:search_allbooks() ;break;case 4:search_borbooks();break;case 5:modify_password();break;case 6 :welcome();break;case 7:exit(0);break;}printf("\nWould you want to back to reader ?<y/n>");answer=getch();putch(answer);if(answer=='y'||answer=='Y')continue;elsebreak;}return;}/******************************************借书******************************************//****************************************************************************** **********/void borrow_books(){FILE *fp,*fp1,*fp2;int i,count=0,j;long int num;int year, month, day,hour,minute,second;struct book bookinf[SIZE];fp=fopen("book_list.txt","rb");for(i=0;i<SIZE;i++)fread(&bookinf[i],sizeof(struct book),1,fp);fclose(fp);for(i=0;i<SIZE;i++){if(bookinf[i].tag==1){count++;}}if(count<topborrow){readerwelcome();printf("Please choice which book you want to borrow number :");scanf("%ld",&num);flushall();for(i=0;i<SIZE;i++){if((num==bookinf[i].booknum)&&(bookinf[i].tag==1)){printf("This book have been borrow!!!");break;}if(num==bookinf[i].booknum){printf("\nbook name:%s\nbook author:%s\nbook type:%s\nBook num:%ld\nbook price:%d\nbook address:%s",bookinf[i].bookname,bookinf[i].author,bookinf[i].type,bookinf[i].booknum,bookinf[i].price,booki nf[i].address);bookinf[i].tag=1;printf("\nYou borrow successful !!!!");write_time();printf("\nYou should return in:");fp2=fopen("time.txt","r");fscanf(fp2,"%d %d %d %d %d %d",&year,&month,&day,&hour,&minute,&second);fprintf(stdout,"%d %d %d %d %d %d",year,month,(day+1),hour,minute,second); /*如果借书时间超过1天划款*/fclose(fp2);fp1=fopen("book_list.txt","wb");for(i=0;i<SIZE;i++)fwrite(&bookinf[i],sizeof(struct book),1,fp1);fclose(fp1);break;}}if(num!=bookinf[i].booknum&&i==SIZE-1)printf("\nOur library doesn't have this book.");}elseprintf("\nYou have borrow two books.If you want to borrow please return some books.");return;}/*********************************************记录借书本的时间********************/void write_time(){FILE *fp;time_t nowtime;int year, month, day,hour,min,sec;struct tm *timeinfo;time( &nowtime );timeinfo = localtime( &nowtime );year = timeinfo->tm_year + 1900;month = timeinfo->tm_mon + 1;day = timeinfo->tm_mday;hour=timeinfo->tm_hour;min=timeinfo->tm_min;sec=timeinfo->tm_sec;fp=fopen("time.txt","w");fprintf(fp,"%d %d %d %d %d %d",year,month,day,hour,min,sec);fclose(fp);return;}/****************************************还书************************************//****************************************************************************** **/void return_books(){FILE *fp,*fp1,*fp2,*fp3;int i,sum,j;long int num;int year, month, day,hour,minute,second;int year1, month1, day1,hour1,minute1,second1;struct book bookinf[SIZE];readerwelcome();printf("\nPlease choice which book you want to return number :");scanf("%ld",&num);flushall();fp=fopen("book_list.txt","rb");if((fp=fopen("book_list.txt","rb"))==NULL){printf("Can't open this file.");exit(0);}for(i=0;i<SIZE;++i)fread(&bookinf[i],sizeof(struct book),1,fp);fclose(fp);for(j=0;j<SIZE;j++){if((num==bookinf[j].booknum)&&(bookinf[j].tag==1)){bookinf[j].tag=0;printf("\nbook name:%s\nbook author:%s\nbook type:%s\nBook num:%ld\nbook price:%d\nbook address:%s",bookinf[j].bookname,bookinf[j].author,bookinf[j].type,bookinf[j].booknum,bookinf[j].price,booki nf[j].address);printf("\nYou borrow in:");fp1=fopen("time.txt","r");if((fp1=fopen("time.txt","r"))==NULL){printf("\nCan't open this file.");exit(0);}fscanf(fp1,"%d %d %d %d %d %d",&year,&month,&day,&hour,&minute,&second);fprintf(stdout,"%d %d %d %d %d %d",year,month,day,hour,minute,second);fclose(fp1);write1_time();if((fp2=fopen("time1.txt","r"))==NULL){printf("\nCan't open this file.");exit(0);}fscanf(fp2,"%d %d %d %d %d %d",&year1,&month1,&day1,&hour1,&minute1,&second1);fclose(fp2);if(((month1-month)==0)&&((day1-day)<1)){fp3=fopen("book_list.txt","wb");for(i=0;i<SIZE;i++)fwrite(&bookinf[i],sizeof(struct book),1,fp3);fclose(fp3);printf("\nYou successful return this book!!!");break;}else{sum=(hour1-hour)/24;printf("\n You should spend %d monney and go on.",sum);break;}}if((num==bookinf[j].booknum)&&(bookinf[j].tag==0)){printf("\nSorry! You doesn't borrow this book!!!");break;}}if(num!=bookinf[j].booknum)printf("\nSorry! Our library doesn't have this book");return;}/********************记录还书的时候的时间用来判断是否超期**********************/void write1_time(){FILE *fp;time_t nowtime;int year, month, day,hour,min,sec;struct tm *timeinfo;time( &nowtime );timeinfo = localtime( &nowtime );year = timeinfo->tm_year + 1900;month = timeinfo->tm_mon + 1;day = timeinfo->tm_mday;hour=timeinfo->tm_hour;min=timeinfo->tm_min;sec=timeinfo->tm_sec;fp=fopen("time1.txt","w");fprintf(fp,"%d %d %d %d %d %d",year,month,day,hour,min,sec);fclose(fp);return;}/*************************************查询书本***********************************//***************************************查询*************************************//***********************************查询你借的书本*******************************/void search_borbooks(){FILE *fp;int i;struct book bookinf[SIZE];fp=fopen("book_list.txt","rb");for(i=0;i<SIZE;i++)fread(&bookinf[i],sizeof(struct book),1,fp);fclose(fp);for(i=0;i<SIZE;i++){if(bookinf[i].tag==1)printf("\nbook name:%s\nbook author:%s\nbook type:%s\nBook num:%ld\nbook price:%d\nbook address:%s",bookinf[i].bookname,bookinf[i].author,bookinf[i].type,bookinf[i].booknum,bookinf[i].price,booki nf[i].address);}if(bookinf[i].tag!=1)printf("\n You doesn't borrow any book.");getch();return;}/********************************查询图书管中的所有图书*************************//****************************************************************************** */void search_allbooks(){int way;char answer='y';while(1){system("cls"); /*清空屏幕*/printf("---------------Welcome to research system--------------\n");printf(" \t1: Search by book name.\n");printf(" \t2: Search by book author.\n");printf(" \t3: Search by book num.\n");printf(" \t0: back\n");printf("\n\n********************************************************************** *******");printf("\n Please choice which way would you want to?<0-3>,other wrong input! ");printf("\n please select which one you want to operate: ");printf("\n*********************************************************************** ******\n");scanf("%d",&way);fflush(stdin); /*清空键盘缓存*/switch(way){case 1:findname();break;case 2:findauthor();break;case 3:findnum();break;case 0:exit(0);/*关闭屏幕*/}printf("\nWould you want to search anther book ?<y/n>");answer=getch();putch(answer);if(answer=='y'||answer=='Y')continue;elsebreak;}return;}/**********************************通过书名来查询********************************/void findname(){FILE *fp;char BookName[40];struct book bookinf[SIZE];int i;system("cls"); /*清空屏幕*/printf("************************************************************************* ******\n");printf(" Welcome to use the name reseach system! \n");printf("************************************************************************* ******\n");printf("\n\t\t\tPlease input book name!");gets(BookName);fp=fopen("book_list.txt","rb");for(i=0;i<SIZE;i++)fread(&bookinf[i],sizeof(struct book),1,fp);fclose(fp);for(i=0;i<SIZE;i++){if(strcmp(BookName,bookinf[i].bookname)==0) /*判断所输入的和储存的一致*/{printf("\nbook name:%s\nbook author:%s\nbook type:%s\nBook num:%ld\nbook price:%d\nbook address:%s",bookinf[i].bookname,bookinf[i].author,bookinf[i].type,bookinf[i].booknum,bookinf[i].price,booki nf[i].address);if(bookinf[i].tag==1)printf("\n\tThe book have been borrow");}}if(strcmp(BookName,bookinf[SIZE].bookname)!=0)printf("\nOur library doesn't have this book.");return;}/*************************通过作者查询****************************************/ void findauthor(){FILE *fp;char Bookauthor[40];int i;struct book bookinf[SIZE];system("cls"); /*清空屏幕*/printf("************************************************************************* ******\n");printf(" Welcome to use the author reseach system! \n");printf("************************************************************************* ******\n");printf("\n\t\t\tPlease input book author!");gets(Bookauthor);fp=fopen("book_list.txt","rb");for(i=0;i<SIZE;i++)fread(&bookinf[i],sizeof(struct book),1,fp);fclose(fp);for(i=0;i<SIZE;i++){if(strcmp(Bookauthor,bookinf[i].author)==0) /*判断所输入的和储存的有没有一致*/{printf("\nbook name:%s\nbook author:%s\nbook type:%s\nBook num:%ld\nbook price:%d\nbook address:%s",bookinf[i].bookname,bookinf[i].author,bookinf[i].type,bookinf[i].booknum,bookinf[i].price,booki nf[i].address);if(bookinf[i].tag==1)printf("\n\tThe book have been borrow");}}if(strcmp(Bookauthor,bookinf[SIZE].author)!=0)printf("\nOur library haven't this book.");fclose(fp);return;}/**************************按图书馆的索引号查询**********************************/void findnum(){FILE *fp;long int num;int i;struct book bookinf[SIZE];system("cls"); /*清空屏幕*/printf("************************************************************************* ******\n");printf(" Welcome to use the num reseach system! \n");printf("************************************************************************* ******\n");fp=fopen("book_list.txt","rb");for(i=0;i<SIZE;i++)fread(&bookinf[i],sizeof(struct book),1,fp);fclose(fp);for(i=0;i<SIZE;i++){if(bookinf[i].booknum==0)break;elseprintf("\nBook num: %ld ",bookinf[i].booknum);}printf("\nPlease input book num!");scanf("%ld",&num);fflush(stdin); /*清空键盘缓存*/for(i=0;i<SIZE;i++){if(num==bookinf[i].booknum) /*判断所输入的和储存的有没有一致*/{printf("\nbook name:%s\nbook author:%s\nbook type:%s\nBook num:%ld\nbook price:%d\nbook address:%s",bookinf[i].bookname,bookinf[i].author,bookinf[i].type,bookinf[i].booknum,bookinf[i].price,booki nf[i].address);if(bookinf[i].tag==1)printf("\n\tThe book have been borrow");break;}}if(num!=bookinf[SIZE].booknum)printf("\nOur library haven't this book.");return;}/****************************************修改密码****************************************/void modify_password() /*修改读者的密码*/{FILE *fp;char pw[4],pw1[4];int i;system("cls"); /*清空屏幕*/printf("************************************************************************* ******\n");printf(" Welcome to use modify password system! \n");printf("************************************************************************* ******\n");while(1){printf("\n\t\tPlease input you want to change password: ");for(i=0;i<4;i++){pw[i]=getch();putch('*');}printf("\n\t\tPlease input you want to change password again: ");for(i=0;i<4;i++){pw1[i]=getch();putch('*');}if(pw[0]==pw1[0]&&pw[1]==pw1[1]&&pw[2]==pw1[2]&&pw[3]==pw1[3]){printf("\n\t\tYou modify successful modify password!");fp=fopen("reader_pw.txt","w");for(i=0;i<4;i++)fprintf(fp,"%c ",pw[i]);fclose(fp);getch();break;}elseprintf("\n\t\tYou input two time password different\n\t\tPlease input again!!!");}return;}。

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

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

图书管理系统/*图书数据由编号、书名、出版社、单价和图书状态(库存用0表示或借出用读者编号表示),读者数据由编号、姓名和电话号码构成。

实现功能包括:(1)添加图书的记录(2)图书管理(借书和还书)(3)对图书数据排序(按单价的降序)(4)删除图书记录(5)修改图书记录(6)添加读者记录(7)输出图书信息表和读者信息表*#include <stdio.h>#include <string.h>#include <stdlib.h>#include <windows.h>/*函数的声明*/void bookname();void writername();void booknumber();void press();void bookdate();void Bfind(); //查询主菜单void Bdevise(); //修改函数void Badd(); //添加函数void Bdelete(); //删除函数void Bdisplay(); //显示所以已保存的图书信息函数void Bclean(); //清除所有图书信息函数void lendbook(); // 借书函数void returnbook(); //还书函数void lendorreturnbook();//借书或还书主菜单函数void appealkey();//用户密码申诉函数void devisepeoplekey();//修改用户密码函数void accountapply(); //用户申请账户函数void addpeopleaccount(); //管理员之添加用户帐号函数void addmanageaccount(); //管理员之添加管理员账号函数void addaccount(); //管理员之账户添加主菜单函数void devisepeopleaccount();//管理员之修改用户账号函数void devisemanageaccount();//管理员之修改管理员帐号函数void deviseaccount();//管理员之修改账号主菜单函数void deletepeopleaccount();//管理员之删除用户账号函数void deletemanageaccount();//管理员之删除管理员账号函数void deleteaccount();//管理员之删除账号主菜单函数void displayallpeopleaccounts();//显示所有用户信息函数void displayallmanageaccounts();//显示所有管理员信息函数void displayallaccountsmessage();//显示所有账号信息主菜单函数void highaddpeopleaccount(); //高级管理员添加用户账户函数void highaddmanageaccount(); //高级管理员添加管理员账户函数void highaddaccount(); //高级管理员之添加账户主菜单函数void booksmanage();//图书操作主菜单函数void accountsmanage();//管理员账号操作主菜单函数void highaccountsmanage();//高级管理员账号操作主菜单函数void menu1(); //用户之查询主菜单void menu2(); //管理员之查询主菜单void menu3(); //高级管理员之查询主菜单/*定义书的类型*/struct book{int bookstock; //库存量char bookname[20]; //书名char bookwriter[20]; //作者char booknumber[20]; //书号char press[20]; //出版社char bookdate[20]; //出版日期char price[20]; //出版价格int turefalse; //判断图书是否被借阅}books[20];/*定义用户类型*/struct peopleaccount{char pname[20];char pkey[20];}peopleaccounts[20];/*定义管理员类型*/struct manageaccount{char mname[20];char mkey[20];}manageaccounts[20];/*定义借书卡类型*/struct card{char cardnumber[20]; //借书卡号和用户信息一起写入yonghu.txt文件中的}cards[20];/*定义文件指针变量*/FILE *fp1; //fp1打开用户信息文件FILE *fp2; //fp2打开管理员信息文件FILE *fp3; //fp3打开图书信息文件FILE *fp4; //打开借还书记录的文件FILE *fpa; //fpa是临时文件指针/*改变输出的字体颜色*/void color(const unsigned short color1){if(color1>=0&&color1<=15)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color1);/*仅限改变0-15的颜色;如果在0-15那么实现他的颜色因为如果超过15后面的改变的是文本背景色。

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

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

C语言课程设计——图书馆管理系统目录第1章引言 (2)1.1 题目背景 (2)1.2 设计目的 (2)1.3 解决问题 (2)第2章使用工具与特点 (4)2.1 C语言的发展 (4)2.2 C语言的特点 (5)第3章总体设计 (6)3.1编写目的 (6)3.2系统功能 (6)第4章系统分析与设计 (12)4.1添加功能设计 (12)4.2借阅图书功能 (13)第5章系统功能实现 (19)5.1添加功能 (19)5.2借阅功能 (19)结论 (22)致谢 (23)第1章引言1.1 题目背景随着计算机技术的飞速发展,改变了世界,也改变了人类的生活。

作为现代科学技术的飞速发展,改变了世界,也改变了人类的生活。

新世纪的大学生,应当站在时代发展的前列,掌握现代科学技术知识,调整自己的知识结构和能力结构,以适应社会发展的要求当今社会,多元文化快速发展,人与人的交流也越来越多,社交也越来越广泛,这时,记住自己认识的人是很重要的,因此我们做了这个程序,为了使我们更有效的记录下自己所认识的人,更方便去和更多的人交流而不会记错。

C语言成了在国内外使用的一种计算机语言。

C语言功能丰富、表达能力强、使用灵活方便、应用面广、目标程序效率高、可移植性好、既具有高级语言的优点,又具有低级语言的许多特点,因此特别适合于编写系统软件。

现在大多数的高校都把C语言作为第一门计算机语言进行教学,这是可行的,学生也是能够学习好的。

1.2 设计目的这次设计主要是应用了C程序设计中的一些算法,还有一些函数的调用,结构体的应用等,根据他们的基本思想来编写程序。

程序包括的主要内容可以对图书馆管理系统进行输入、修改、删除、借阅、归还、显示等操作,设计一个有关学生借阅图书的管理程序,来方便人们对信息更方便的使用,经过这样一个过程来巩固和完善自己所学的知识,同时来培养一下自己的实践能力。

通过本设计可以加深理解利用程序设计思想开发一个系统的整个流程,提高分析问题、解决问题和实际动手的能力。

图书管理系统c语言

图书管理系统c语言

图书管理系统C语言1. 简介图书管理系统是一种用于管理图书馆藏书和借阅记录的软件系统。

它通常包括图书的录入、借阅、归还、查询等功能,能够提高图书馆的工作效率和服务质量。

本文将使用C语言编写一个简单的图书管理系统,实现基本的图书信息录入、修改、查询、借阅、归还等功能。

2. 功能实现2.1 数据结构我们首先需要定义合适的数据结构来存储图书信息和借阅记录。

以下是一个简单的数据结构示例:struct Book {int id; // 图书编号char title[100]; // 图书标题char author[50]; // 图书作者char category[50]; // 图书分类int isBorrowed; // 图书是否已借阅,0表示未借阅,1表示已借阅char borrowerName[100]; // 借阅者姓名// 可根据需求扩展其他字段};struct BorrowRecord {int bookId; // 图书编号char borrowerName[100]; // 借阅者姓名char borrowDate[20]; // 借阅日期char returnDate[20]; // 归还日期// 可根据需求扩展其他字段};2.2 图书信息录入和修改我们可以通过实现相应的函数来实现图书信息的录入和修改。

以下是一个简单的示例:void addBook(struct Book *library, int *count) {// 输入图书信息,将其存入library数组中,同时更新count}void updateBook(struct Book *library, int count, int bookId) { // 根据图书编号bookId,更新library数组中对应图书的信息}2.3 图书查询我们可以根据图书的不同字段来实现不同的查询功能,比如根据图书标题、作者、分类等进行模糊查询,或根据图书编号进行精确查询。

图书管理系统(c语言)

图书管理系统(c语言)

fclose(fp2);
fp=fopen("record.txt","w");
fp2=fopen("bookl.txt","r");
for(i=0;fread(&student[i],sizeof(struct student),1,fp2)!=0;i++)
{ fwrite(&student[i],sizeof(struct student),1,fp); /*
判断是否借阅了输入的书 */
if(strcmp(student[i].lendbook,lendbook)==0) /* {
借阅了该书,进入下一循环,否则出错显示 */
fclose(fp);
fp=fopen("record.txt","r");
fp2=fopen("bookl.txt","w");
for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++)
n=n+1;
}
fclose(fp);
printf(" 目前共有 %d本书借出 \n",n);
printf(" 按任意键 \n");
getch();
}
chabook()
{
char ch5;
do
{
printf("---------------
欢迎进入图书查询系统! --------------\n");
卡号存在,进入下一循环 */

图书管理系统(C语言)

图书管理系统(C语言)

目录总体设计 (3)模块分析 (3)欢迎界面 (3)图书销售系统主界面 (4)图书信息录入功能 (5)图书信息浏览功能 (6)图书信息查询功能 (7)图书信息删除功能 (11)图书信息修改功能 (12)图书信息排序功能 (14)图书购买及账单打印功能 (18)总结 (19)部分源代码附录 (20)一、总体设计在图书销售系统中,系统以菜单方式工作。

能够实现图书信息的录入、浏览、查询、删除、修改、排序以及购买和账单打印功能。

每种功能都编写成一个子函数,由主函数进行选择调用。

经过调试,效果比较理想,完成了设计要求。

现将设计框图列举如下:二、模块分析【1】 欢迎界面源代码:void welcome()//欢迎界面{system("cls");printf("┴┬┴┬/ ̄\_/ ̄\ \n");printf("\n"); printf("┬┴┬┴▏ ▏▔▔▔▔\");printf(" 〓━〓━〓━〓━〓 〓━〓━〓━〓━〓━〓\n");printf("\n"); printf("┴┬┴/\ / ﹨");printf(" 〓 欢迎使用图书销售系统(QIN 1.0版) 〓\n");printf("\n");欢迎界面 图书销售系统界面 1录入 2浏览 3查询 5修改 6排序 4删除 7购买 1按书名 2按作者名 1按价格 2按书名 1精确查询 2模糊查询printf("┬┴∕/)");printf(" 〓━〓━〓━〓〓━〓━〓━〓━〓━〓━〓\n");printf("\n");printf("┴┬▏●▏\n");printf("\n");printf("┬┴▏钦ge ▔█◤\n ");printf("\n");printf("┴◢██◣\__/");printf(" 制造者:陈钦\n");printf("\n");printf("┬█████◣/");printf("\t _╱╲↗\n");printf("\n");printf("┴█████████████◣");printf("\t _╱╲↗ \n");printf("\n");printf("◢██████████████▆▄\n");printf("\n");printf("◢██████████████▆▄\n");printf("\n");printf("█◤◢██◣◥█████████◤\\n");printf("\n");printf("按回车继续……");fflush(stdin);getchar();}该欢迎界面是参考一些网站资料得到的,比较人性化。

图书馆管理系统设计(C语言)教学文稿

图书馆管理系统设计(C语言)教学文稿
for(i=0;i<78;i++)
printf("%c",196); /*画水平直线*/
printf("%c",191);/*画右上角*/
for(i=3;i<=23;i++)
{
gotoxy(1,i);
printf("%c",179); /*画垂直线*/
gotoxy(80,i);
printf("%c",179);
3)变量及类型:void DrawFrame(int l,int u,int r,int d,int tcolor,int bcolor)
{
textbackground(bcolor); /*背景颜色*/
textcolor(bcolor); /*文本颜色*/
for(i=l;i<=r;i++) /*输出背景区域*/
gotoxy(r,i);
cprintf("%c",179);
}
for(i=l+1;i<r;i++)
{
gotoxy(i,u);
cprintf("%c",196); /*水平线*/
gotoxy(i,d);
cprintf("%c",196);
}
gotoxy(l,u);
cprintf("%c",218);/*左上角*/
gotoxy(r,u);
cprintf("%c",191);/*右上角*/
gotoxy(l,d);
1.3主要功能要求:
功能分析:从图书馆的管理功能上分析,图书馆一共有三个方面的需求。

图书管理系统的设计(C语言)

图书管理系统的设计(C语言)

图书管理系统设计图书管理信息包括:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等功能描述:1 .新进熟土基本信息的输入2 .图书基本信息的查询3 .对撤销图书信息的删除4 .为借书人办理注册5 .办理借书手续6 .办理换书手续要求:以文件方式存储数据,系统以菜单方式工作。

这是本人大一第二学期初 C 语言课程设计的作品,嘿嘿,本来以为已经找不到原稿了,今天无意中居然在QQ 网络硬盘中找到了当初的teta 版,发布于此,以作记念。

C 源代码如下:#include〈stdio 。

h〉#include<stdlib。

h〉#include〈string 。

h>struct book {char book_name [30];int bianhao;double price;char author[20];char state [20] ;char name[20];char sex [10];int xuehao;struct book *book_next;};struct club {char name [20];char sex[10];int xuehao;char borrow [30];struct club *club_next;};void Print_Book(struct book *head_book);/*浏览所有图书信息*/void Print_Club(struct club *head_club);/*浏览所有会员信息*/struct book *Create_New_Book();/*创建新的图书库, 图书编号输入为0 时结束*/struct book *Search_Book_bianhao(int bianhao,struct book *head_book);struct book *Search_Book_name (char *b_name,struct book *head_book);struct book *Search_Book_price (double price_h,double price_l,struct book *head_book);struct book *Insert_Book (struct book *head_book,struct book *stud_book) ;/*增加图书,逐个添加*/struct book *Delete_Book(struct book *head_book,int bianhao);/*删除图书*/struct club *Create_New_Club() ;struct club *Search_Club_xuehao(int xuehao,struct club *head_club);struct club *Search_Club_name (char *c_name,struct club *head_club);struct club *Insert_Club (struct club *head_club,struct club *stud_club);struct club *Delete_Club (struct club *head_club,int xuehao);struct book *Lent_Book (int bianhao ,int xuehao,struct book *head_book,struct club *head_club);struct book *back (int bianhao,int xuehao,struct book *head_book,struct club *head_club); int main(){struct book *head_book,*p_book;char book_name [30],name [20],author [20],sex [10];int bianhao;double price,price_h,price_l;int size_book=sizeof(struct book);int m=1,n=1,f;char *b_name,*c_name;struct club *head_club,*p_club;int xuehao;int size_club=sizeof (struct club) ;int choice;printf ("\n 欢迎您第一次进入图书管理系统!\n\n");printf("---——>[向导]————-〉[新建图书库] \n\n”) ;printf ("注意:当输入图书编号为0 时,进入下一步.\n\n");head_book=Create_New_Book();system(”cls”) ;printf("\n 欢迎您第一次进入图书管理系统!\n\n") ;printf("----—〉[向导]——---〉[新建会员库]\n\n”);printf(”注意:当输入会员学号为0 时,进入主菜单.\n\n”);head_club=Create_New_Club () ;system (”cls”);do {printf(”\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n”);printf("\n”);printf ("\t\t\t[1] :借书办理\t");printf(" [6]:还书办理\n”);printf (”\n");printf(”\t\t\t[2]:查询图书\t");printf(" [7]:查询会员\n”);printf (” \t\t\t[3]:添加图书\t");printf (" [8]:添加会员\n”);printf ("\t\t\t[4]:删除图书\t");printf (” [9] :删除会员\n") ;printf (” \t\t\t[5]:遍历图书\t");printf (” [10]:遍历会员\n\n”) ;printf ("\t\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n\n”);printf("\t\t\t0:退出\n\n”) ;printf(”请选择〈0~10〉:”);scanf(”%d",&choice);switch(choice) {case 1:printf ("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");printf (”输入所借图书编号:\n");scanf (”%d",&bianhao);printf ("输入借书人的学号:\n”);scanf ("%d",&xuehao);head_book=Lent_Book(bianhao,xuehao,head_book,head_club);system (”cls");printf (” \n 借阅成功!\n\n");printf (”相关信息如下:\n\n");head_book=Search_Book_bianhao (bianhao,head_book);break;case 2:system ("cls”) ;printf(”\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n”); printf ("1。

c语言图书馆管理系统(codeblocks版)

c语言图书馆管理系统(codeblocks版)
printf("\t--------ID: %40s--------\n", p1->ID);
printf("\t--------PASS: %40s--------\n", p1->pass);
printf("\t--------LEVEL:%40d--------\n", p1->level);
/*
*图书馆管理系统
*@author琴卓
*@time 2015-12-10
*/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include<windows.h>
#define PASS_LEN 20 //密码长度
int lendsum;
struct user *next;
}user;
//用户结构体简写为bokk
typedef struct book {
char name[20];
char author[20];
char publish[20];
char year[10];
char ISBN[40];
char state[10];
char choice;
//程序入口
void main()
{
system("color 8b");
system("mode con cols=100 lines=50");
printf("\t\t\t图书馆系统细则:\n\t\t1.新用户注册由系统管理员操作\n\t\t2.图书由图书管理员负责\n\t\t3.普通用户最多借3本书为期30天,可续借一次,\n\t\t超期不换将每天扣除0.1元,超过10元账户将冻\n\t\t结,届时无法完成登录,需要找系统管理员解冻\n\t\t4.密码输入支持退格,访问级别1代表普通用户\n\t\t5.单项数据输入不支持空格\n\t\t6.程序每关闭开启一次经过6天\n");

c语言实现图书管理系统

c语言实现图书管理系统

c语⾔实现图书管理系统前⾔⽤C语⾔实现⼀个图书管理系统简单的那种。

简单。

运⾏环境:vs2013效果1.主界⾯2.查看库存3.录⼊书籍4.删除书籍5.查询书籍6.价格排序7.修改信息8.退出完整代码/*************************************** Author:拾荒荒* Note:more...***************************************/#include <stdio.h>#include <stdlib.h>#include <assert.h>#include <string.h>#define EMPTY -1 // 初始标志#define DEL_EMPTY 0 // 删除标志#define _MAX 200 //库存最⼤数量typedef struct BookInfo {int _count;int _price;char _id[10];char _author[20];char _name[50];char _introduction[100];}BookData;BookData books_house[_MAX] = { -1, 0,"","", "", "", };// 书仓信息void books_house_info(){printf("--------------------书籍信息--------------------\n");printf("ID\t书名\t作者\t价格\t数量\t简介\n");for (int i = 0; i < _MAX; ++i) {if (books_house[i]._count == EMPTY)break;else if (books_house[i]._count == DEL_EMPTY)continue;printf("%s\t", books_house[i]._id);printf("%s\t", books_house[i]._name);printf("%s\t", books_house[i]._author);printf("%d\t", books_house[i]._price);printf("%d\t", books_house[i]._count);printf("%s\t", books_house[i]._introduction);printf("\n");}printf("------------------------------------------------\n");}// 增添书bool books_house_add(BookData info){for (int i = 0; i < _MAX; ++i) {if (books_house[i]._count == EMPTY ||books_house[i]._count == DEL_EMPTY) {for (int j = 0; j < _MAX; ++j) {if (strcmp(books_house[j]._id, info._id) == 0 ||strcmp(books_house[j]._name, info._name) == 0) {return false;}}books_house[i] = info; break;}}books_house_info();return true;}// 删除书void books_house_del(BookData info){for (int i = 0; i < _MAX; ++i) {if (strcmp(books_house[i]._name, info._name) == 0) {books_house[i]._count = DEL_EMPTY;break;}}books_house_info();}// 价格排序(升序)void books_house_sort(){for (int i = 0; i < _MAX - 1; ++i) {if (books_house[i]._count == EMPTY) break;else if (books_house[i]._count == DEL_EMPTY) continue; for (int j = 0; j < _MAX - i - 1; ++j) {if (books_house[j]._price > books_house[j + 1]._price) { BookData tmp = books_house[j];books_house[j] = books_house[j + 1];books_house[j + 1] = tmp;}}}books_house_info();}// 修改书籍信息void books_house_modify(BookData info){for (int i = 0; i < _MAX; ++i) {if (strcmp(books_house[i]._name, info._name) == 0) {books_house[i] = info; break;}}books_house_info();}// 根据书ID查找bool books_house_search(BookData info){printf("\n--------------------查询结果--------------------\n");printf("ID\t书名\t作者\t价格\t数量\t简介\n");for (int i = 0; i < _MAX; ++i) {if (strcmp(books_house[i]._id, info._id) == 0) {printf("%s\t", books_house[i]._id);printf("%s\t", books_house[i]._name);printf("%s\t", books_house[i]._author);printf("%d\t", books_house[i]._price);printf("%d\t", books_house[i]._count);printf("%s\t", books_house[i]._introduction);printf("\n");return true;break;}}return false;}void set_book_info(BookData *book){printf("输⼊ID:");scanf_s("%s", book->_id, sizeof(book->_id));printf("输⼊书名:");scanf_s("%s", book->_name, sizeof(book->_name));printf("输⼊作者:");scanf_s("%s", book->_author, sizeof(book->_author));printf("输⼊简介:");scanf_s("%s", book->_introduction, sizeof(book->_introduction));printf("输⼊数量:");scanf_s("%d", &book->_count);printf("输⼊价格:");scanf_s("%d", &book->_price);}void books_house_manage_menu(){system("cls");printf(" 图书管理系统 \n\n");printf(" | 1.查看库存 |\n");printf(" 2.录⼊书籍 \n");printf(" | 3.删除书籍 |\n");printf(" 4.查询书籍 \n");printf(" | 5.价格排序 |\n");printf(" 6.修改信息 \n");printf(" | 7.退出 |\n");printf("\n-----\n");printf("请问你想操作什么: ");}int main(int argc, char **argv){do {int select;books_house_manage_menu();scanf_s("%d", &select);switch (select){case 1: {books_house_info();break;}case 2: {BookData book;set_book_info(&book);books_house_add(book) ? NULL : printf("**该书籍已存在!请勿重复输⼊!\n"); break;}case 3: {BookData book;printf("输⼊需要删除的书名:");scanf_s("%s", book._name, sizeof(book._name));books_house_del(book);break;}case 4: {BookData book;printf("输⼊需要查询的ID号:");scanf_s("%s", book._id, sizeof(book._id));books_house_search(book);break;}case 5: {books_house_sort();break;}case 6: {BookData book;printf("输⼊需要修改书籍的ID:");scanf_s("%s", book._id, sizeof(book._id));if (books_house_search(book)) {printf("请输⼊以下提⽰的修改信息\n");set_book_info(&book);books_house_modify(book);}break;}return 0;}default:break;}printf("\n");system("pause"); } while (true);return 0;}_End。

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

按钮。

如图2所示图2新建工程最后在“新建工程信息”对话框中,单击“确定”按钮,完成项目的建立。

图3创建空工程图4创建源程序编程运行后就可以使用了,可以查阅图书,比如书籍的序号、书名、以及作者等。

借阅图书模块查询学生的借书信息等。

管理系统模块包括员工的管理和书籍的管理。

还书模块,学生还书后系统就会清楚借书记录。

最后模块是退出功能使用后可以退出系统。

按照如图5所示进行相关操作。

图5系统操作界面3.2图书管理模块设计3.2.1书籍统计书籍统计的程序,通过该程序的正确运行可以查阅图书、借阅图书、管理图书以及还书的相关操作。

选择3管理图书然后会显示下一界面再选择4就可以进行书籍统计了,结果如图6所示。

图6书籍统计书籍统计函数bookcount(){FILE *fp;int i,n=0;fp=fopen("book.txt","r");for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++){if(book[i].booknum!=0&&strlen(book[i].bookname)!=0&&strlen(book[i].bookcreat)!=0){printf("第%d本书<序号:%d 书名:%s 作者:%s 状态:%d>\n",i+1,book[i].booknum,book[i].bookname,book[i].bookcreat,book[i].turefalse);n=n+1;} }fclose(fp);printf("目前共有%d本书\n",n);printf("按任意键\n");3.2.2删除图书删除图书的程序,程序运行后可以选择相关选项,选择删除图书来进行图书删除,删除图书之前会显示警告是否真的要删除该图书,以便操作者误删图书。

运行结果如图7所示。

图7删除图书删除图书成功如图8所示图8删除成功删除图书函数delbook(){FILE *fp,*fp2;int i;char bookname[10],choice;fp=fopen("book.txt","r");fp2=fopen("bookl.txt","w");printf("请输入你要删除的书名\n");printf("如果你输入的书名存在,系统自动删除该信息!如果不存在,系统不做任何改动\n"); scanf("%s",bookname);for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++){if(strcmp(bookname,book[i].bookname)!=0){fwrite(&book[i],sizeof(struct book),1,fp2);}}fclose(fp);fclose(fp2);printf("是否真的要删除该书籍?删除后该书籍的所有信息将无法恢复《Y/N》\n");scanf("%s",&choice);if(choice=='y'||choice=='Y'){fp=fopen("book.txt","w");fp2=fopen("bookl.txt","r");for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++){fwrite(&book[i],sizeof(struct book),1,fp);}fclose(fp);fclose(fp2);fp2=fopen("bookl.txt","w");fclose(fp2);printf("按任意键返回\n");getch();return;}else{printf("按任意键返回\n");getch();return;}}3.2.3修改图书资料修改图书资料程序,运行后可以根据预期结果来进行相关操作,修改图书资料包括修改图书序号、书名、和作者。

运行结果如图9所示。

图9 图书资料修改图书资料修改成功后统计结果如图10所示图10 图书资料修改成功修改图书资料函数changebook(){FILE *fp,*fp2;char bookname[10],choice;int i;fp=fopen("book.txt","r");fp2=fopen("bookl.txt","w");printf("请你输入要修改的书籍的书字\n");scanf("%s",bookname);for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++){if(strcmp(book[i].bookname,bookname)==0){printf("你所要修改的书的资料如下,请选择你要修改的内容\n");printf("序号:〈%d〉书名:〈%s〉作者:〈%s〉\n",book[i].booknum,book[i].bookname,book[i].bookcreat);printf("1:修改书的序号\n");printf("2:修改书名\n");printf("3:修改作者\n");printf("请输入1-3:");scanf("%s",&choice);switch(choice){case '1':{printf("请输入新的序号\n");scanf("%d",&book[i].booknum);fwrite(&book[i],sizeof(struct book),1,fp2);#include<stdlib.h>#include<ctype.h>#define STACK_INIT_SIZE 10#define OK 1#define TRUE 1#define FALSE 0#define ERROR 0struct student /*定义学生类型,用于存放借出的书籍*/{int carnum;char lendbook[10];}student[1000];struct employ /*定义职工类型*/{int employnum;char employname[15];int employage;char employsex[2];char employleve[10];long int employtage;}employ[50];struct book /*定义书的类型*/{int booknum;char bookname[10];char bookcreat[10];int turefalse; /*用于借书和还书模块判断一本书是否借出的条件*/ }book[1000];struct car /*借书卡的数据类型*/{int carnum;char studentname[10];int studentclass;}car[100];huanbook() /*还书函数*/{FILE *fp,*fp2; /*定义两个文件指针,fp2用于修改数据时设立临时文件用,防止数据遭破坏*/int i,n;int carnum;char lendbook[10];printf("请你输入你的卡号\n");fp=fopen("car.txt","r"); /*读取卡号记录*/for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++) /*for循环判断卡号是否存在*/{if(car[i].carnum==carnum) /*卡号存在,进入下一循环*/{n=i;fclose(fp);printf("请输入你要还的书的名字\n");scanf("%s",lendbook);fp=fopen("record.txt","r");for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++) /*判断是否借阅了输入的书*/{if(strcmp(student[i].lendbook,lendbook)==0) /*借阅了该书,进入下一循环,否则出错显示*/{fclose(fp);fp=fopen("record.txt","r");fp2=fopen("bookl.txt","w");for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++){if(strcmp(student[i].lendbook,lendbook)==0){continue; /*删除还掉的书的借书记录*/}fwrite(&student[i],sizeof(struct student),1,fp2); /*写入原来没还的书的记录*/}fclose(fp);fclose(fp2);fp=fopen("record.txt","w");fp2=fopen("bookl.txt","r");for(i=0;fread(&student[i],sizeof(struct student),1,fp2)!=0;i++){fwrite(&student[i],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(&book[i],sizeof(struct book),1,fp)!=0;i++) /*将书的记录写入临时文件,防止因为修改信息破坏以前的记录*/{if(i==n){book[i].turefalse=1;fwrite(&book[i],sizeof(struct book),1,fp2); /*将还的书的原来状态设为无人借阅的*/continue;}fwrite(&book[i],sizeof(struct book),1,fp2);fclose(fp);fclose(fp2);fp=fopen("book.txt","w");fp2=fopen("bookl.txt","r");for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++){fwrite(&book[i],sizeof(struct book),1,fp); /*将临时文件写回*/}fclose(fp);fclose(fp2);fopen("bookl.txt","w"); /*清临时文件*/fclose(fp2);printf("还书完毕,按任意键返回\n");getch();return 1;}}printf("你没有借这样的书,任意键返回\n"); /*出错提示*/fclose(fp);getch();return 0;}}printf("系统没这样的卡,和管理员联系,按任意键返回\n"); /*出错提示*/ fclose(fp);getch();}findbook(){char bookname[10];int ture,i;fp=fopen("book.txt","r");printf("请输入你要查找的书名\n");scanf("%s",bookname);for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++){if(strcmp(bookname,book[i].bookname)==0){if(book[i].turefalse==1){printf("这本书的详细资料是:%d %s %s 此书现在无人借阅\n按任意键返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat);}else {printf("这本书已经有人借出\n");fclose(fp);return 0;}fclose(fp);return FALSE;}}printf("没有你要查询的书籍\n");fclose(fp);return FALSE;}findbook1(){FILE *fp;char bookcreat[10];int ture,i;fp=fopen("book.txt","r");printf("请输入你要查找的作者名\n");scanf("%s",bookcreat);for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++){if(strcmp(bookcreat,book[i].bookcreat)==0){if(book[i].turefalse==1){printf("这本书的详细资料是:%d %s %s 此书现在无人借阅\n按任意键返回\n",book[i].booknum,book[i].bookname,book[i].bookcreat);}else {printf("这本书已经有人借出\n");fclose(fp);return 0;}fclose(fp);return FALSE;}}printf("没有你要查询的书籍\n");fclose(fp);return FALSE;}lendcount(){FILE *fp;int i,n=0;fp=fopen("record.txt","r");for(i=0;fread(&student[i],sizeof(struct student),1,fp)!=0;i++){printf("卡号:%d 借出的书籍:%s \n",student[i].carnum,student[i].lendbook);n=n+1;}fclose(fp);printf("目前共有%d本书借出\n",n);printf("按任意键\n");getch();return n;}chabook(){char ch5;do{printf("---------------欢迎进入图书查询系统!--------------\n"); printf(" 1:<按书名查找>\n");printf(" 2:<按作者查找>\n");printf(" 0:<返回>\n");printf("请输入0--2,其他输入非法!\n");scanf("%s",&ch5);switch(ch5){case '1':findbook();getch();break;case '2':findbook1();getch();break;case '0':break;default:printf("无此操作\n");getch();break;}}while(ch5!='0');return FALSE;}lendbook(){FILE *fp,*fp2;int i,n;int carnum;printf("请你输入你的卡号\n");scanf("%d",&carnum);fp=fopen("car.txt","r");for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++){if(car[i].carnum==carnum){n=i;fclose(fp);printf("请输入你要借阅的书的名字\n");scanf("%s",student[n].lendbook);fp=fopen("book.txt","r");for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++){if(strcmp(book[i].bookname,student[n].lendbook)==0){if(book[i].turefalse==0) {printf("对不起,此书有人借出,请借其他书\n");fclose(fp);getch();return;}elsefclose(fp);fp=fopen("record.txt","a+");student[n].carnum=carnum;fwrite(&student[n],sizeof(struct student),1,fp);fclose(fp);fp=fopen("book.txt","r");fp2=fopen("bookl.txt","w");for(i=0;fread(&book[i],sizeof(struct book),1,fp)!=0;i++){if(strcmp(book[i].bookname,student[n].lendbook)==0) {book[i].turefalse=0;fwrite(&book[i],sizeof(struct book),1,fp2);continue;}fwrite(&book[i],sizeof(struct book),1,fp2);}fclose(fp);fclose(fp2);fp=fopen("book.txt","w");fp2=fopen("bookl.txt","r");for(i=0;fread(&book[i],sizeof(struct book),1,fp2)!=0;i++) {fwrite(&book[i],sizeof(struct book),1,fp);}fclose(fp);fclose(fp2);fopen("bookl.txt","w");fclose(fp2);printf("借书完毕,按任意键返回\n");getch();return;}}printf("不存在这样的书,任意键返回\n");fclose(fp);getch();return;}}printf("你的卡号不存在,请申请新卡,按任意键返回\n");fclose(fp);getch();}carcount(){FILE *fp;int i,n=0;fp=fopen("car.txt","r");for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++){printf("第%d张卡<卡号:%d 姓名:%s 班级:%d>\n",i+1,car[i].carnum,car[i].studentname,car[i].studentclass);n=n+1;}fclose(fp);printf("目前共有%d本书\n",n);printf("按任意键\n");getch();}delcar(){FILE *fp,*fp2;int i;int carnum;char choice;fp=fopen("car.txt","r");fp2=fopen("bookl.txt","w");printf("请输入你要删除的卡号\n");printf("如果你输入的卡号存在,系统自动删除该信息!如果不存在,系统不做任何改动\n"); scanf("%d",&carnum);for(i=0;fread(&car[i],sizeof(struct car),1,fp)!=0;i++){if(car[i].carnum!=carnum){fwrite(&car[i],sizeof(struct car),1,fp2);}}fclose(fp);fclose(fp2);printf("是否真的要删除该卡?删除后该书籍的所有信息将无法恢复《Y/N》\n");scanf("%s",&choice);if(choice=='y'||choice=='Y'){fp=fopen("car.txt","w");fp2=fopen("bookl.txt","r");for(i=0;fread(&car[i],sizeof(struct car),1,fp2)!=0;i++){fwrite(&car[i],sizeof(struct car),1,fp);}fclose(fp);fclose(fp2);fp2=fopen("bookl.txt","w");fclose(fp2);printf("按任意键返回\n");getch();return;}{printf("按任意键返回\n");getch();return;}}addcar(){FILE *fp;int i=0;fp=fopen("car.txt","a+");printf("请你输入卡号\n");scanf("%d",&car[i].carnum);printf("请你输入学生姓名\n");scanf("%s",car[i].studentname); printf("请你输入班级\n");scanf("%d",&car[i].studentclass); fwrite(&car[i],sizeof(struct car),1,fp); fclose(fp);printf("输入完毕,任意键返回\n"); getchar();return;}getch();return TRUE;}else{printf("按任意键返回\n");return FALSE;}}fclose(fp);}addbook(){FILE *fp;int i=0;char choice='y';fp=fopen("book.txt","a+");while(choice=='y'||choice=='Y'){printf("请你输入第%d本书的序号\n",i+1);scanf("%d",&book[i].booknum);printf("请你输入书名\n");scanf("%s",book[i].bookname);printf("请你输入书的作者\n");getch();return;}else{printf("按任意键返回\n");getch();return;}}getchar();}main(){char ch1,ch2,ch3,ch4,ch5;do{printf("\t\t请你选择操作类型:\n");printf(" 1:<查阅图书>\n");printf(" 2:<借阅图书>\n");printf(" 3:<管理系统>\n");printf(" 4:<还书>\n");printf(" 0:<退出>\n");printf("请输入0--4\n");scanf("%s",&ch1);switch(ch1){case '1':chabook();break;case '2':lendbook();;break;case '3':{do{printf("---------------欢迎进入管理系统!--------------\n");printf(" 1:<增加图书>\n");printf(" 2:<删除图书>\n");printf(" 3:<修改图书资料>\n");printf(" 4:<书籍统计>\n");printf(" 5:<职工管理系统>\n");printf(" 6:<学生管理系统>\n");printf(" 0:<返回>\n");scanf("%s",&ch2);switch(ch2){case '1':addbook();break;case '2':delbook();break;case '3':changebook();break;case '4':bookcount();getch();break;case '5':{do{ printf("---------------欢迎进入职工管理系统!--------------\n");printf(" 1:<增加员工>\n");printf(" 2:<删除员工>\n");printf(" 3:<修改员工资料>\n");printf(" 4:<员工统计>\n");printf(" 0:<返回>\n");printf("请输入0--4,其他输入非法!\n");scanf("%s",&ch3);switch(ch3){case '1':addemploy();getch();break;case '2':delemploy();break;case '3':changemploy();break;case '4':employcount();getch();break;case '0':break;default:printf("无此操作\n");getch();break;}}while(ch3!='0');}break;case '6':{doprintf("---------------欢迎进入学生管理系统!--------------\n"); printf(" 1:<申请新卡>\n");printf(" 2:<删除卡号>\n");printf(" 3:<借书统计>\n");printf(" 4:<卡号统计>\n");printf(" 0:<返回>\n");printf("请输入0--4,其他输入非法!\n");scanf("%s",&ch4);switch(ch4){case '1':addcar();break;case '2':delcar();break;case '3':lendcount();break;case '4':carcount();break;case '0':break;default:printf("无此操作\n");getch();break;}}while(ch4!='0');}break;case '0':break;default:printf("无此操作\n");getch();break;}。

相关文档
最新文档