c语言-图书管理系统(1)doc资料
- 格式:doc
- 大小:46.00 KB
- 文档页数:15
图书管理系统设计图书管理信息包括:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等功能描述:1.新进熟土基本信息的输入2.图书基本信息的查询3.对撤消图书信息的删除4.为借书人办理注册5.办理借书手续6.办理换书手续要求:以文件方式存储数据,系统以菜单方式工作。
这是本人大一第二学期初C语言课程设计的作品,嘿嘿,本来以为已经找不到原稿了,今天无意中竟然在QQ网络硬盘中找到了当初的teta版,发布于此,以作纪念。
C源代码如下:#include<stdio.h>#include<stdlib.h>#include<string.h>struct book{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;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.按编号查询\n\n");printf("2.按名称查询\n\n");printf("3.按价格区间查询\n\n");printf("0.返回主菜单\n\n");printf("请选择:");scanf("%d",&f);if(f==1){printf("请输入查询图书编号:");scanf("%d",&bianhao);printf("相关信息如下:\n\n");head_book=Search_Book_bianhao(bianhao,head_book); break;}else if(f==2){b_name=book_name;getchar();printf("请输入查询图书名称:");gets(b_name);printf("相关信息如下:\n\n");head_book=Search_Book_name(b_name,head_book);break;}else if(f==3){printf("请输入最高价格:");scanf("%lf",&price_h);printf("请输入最低价格:");scanf("%lf",&price_l);printf("相关信息如下:\n\n");head_book=Search_Book_price(price_h,price_l,head_book); break;}else if(f==0){break;}break;case 6:printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n"); printf("输入所还图书编号:\n");scanf("%d",&bianhao);printf("输入还书人的学号:\n");scanf("%d",&xuehao);head_book=back(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 3:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");printf("请输入图书名称:");scanf("%s",book_name);printf("请输入图书编号:");scanf("%d",&bianhao);printf("请输入单价:");scanf("%lf",&price);printf("请输入作者名字:");scanf("%s",author);printf("\n");struct book *ptr_b;for(ptr_b=head_book;ptr_b;ptr_b=ptr_b->book_next){if(ptr_b->bianhao==bianhao){printf("此编号图书已存在\n"); m=0;break;}}if(m){p_book=(struct book *)malloc(size_book);strcpy(p_book->book_name,book_name);p_book->bianhao=bianhao;p_book->price=price;p_book->xuehao=0;strcpy(p_book->author,author);strcpy(p_book->state,"存在");strcpy(p_book->sex,"待定");strcpy(p_book->name,"待定");head_book=Insert_Book(head_book,p_book);printf("\n添加图书成功!\n\n");}break;case 4:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");printf("输入删除图书编号:\n");scanf("%d",&bianhao);head_book=Delete_Book(head_book,bianhao);printf("\n删除图书成功!\n\n");break;case 5:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n"); Print_Book(head_book);break;case 7:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n"); printf("1.按学号查询\n\n");printf("2.按姓名查询\n\n");printf("0.返回主菜单\n\n");printf("请选择:");scanf("%d",&f);if(f==1){printf("请输入查询会员学号:");scanf("%d",&xuehao);printf("相关信息如下:\n\n");head_club=Search_Club_xuehao(xuehao,head_club);break;}else if(f==2){c_name=name;getchar();printf("请输入查询会员姓名:");gets(c_name);printf("相关信息如下:\n\n");head_club=Search_Club_name(c_name,head_club);break;}else if(f==0){break;}break;printf("请输入查询会员学号:\n");scanf("%d",&xuehao);printf("相关信息如下:\n\n");break;case 8:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n"); printf("请输入会员名字:");scanf("%s",name);printf("请输入会员性别:");scanf("%s",sex);printf("请输入会员学号:");scanf("%d",&xuehao);printf("\n");struct club *ptr_c;for(ptr_c=head_club;ptr_c;ptr_c=ptr_c->club_next){if(ptr_c->xuehao==xuehao){printf("此学号会员已存在\n");n=0; break; }}if(n){p_club=(struct club *)malloc(sizeof(struct club));strcpy(p_club->name,name);strcpy(p_club->sex,sex);p_club->xuehao=xuehao;strcpy(p_club->borrow,"暂无");head_club=Insert_Club(head_club,p_club);printf("\n添加会员成功!\n\n");}break;case 9:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");printf("输入要删除会员学号:\n");scanf("%d",&xuehao);head_club=Delete_Club(head_club,xuehao);printf("\n删除会员成功!\n\n"); break;case 10:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");Print_Club(head_club); break;case 0:system("cls");printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n");printf("\n谢谢您的使用!\n\n"); break;}}while(choice!=0);return 0;}struct book *Create_New_Book(){struct book *head_book,*p_book;int bianhao;double price;char book_name[30],author[20];int size_book=sizeof(struct book);head_book=NULL;printf("请输入图书名称:");scanf("%s",book_name);printf("请输入图书编号:");scanf("%d",&bianhao);printf("请输入单价:");scanf("%lf",&price);printf("请输入作者名字:");scanf("%s",author);printf("\n");while(bianhao!=0){p_book=(struct book *)malloc(size_book);strcpy(p_book->book_name,book_name);p_book->bianhao=bianhao;p_book->price=price;p_book->xuehao=0;strcpy(p_book->author,author);strcpy(p_book->state,"存在");strcpy(p_book->sex,"待定");strcpy(p_book->name,"待定");head_book=Insert_Book(head_book,p_book);printf("请输入图书名称:");scanf("%s",book_name);printf("请输入图书编号:");scanf("%d",&bianhao);printf("请输入单价:");scanf("%lf",&price);printf("请输入作者名字:");scanf("%s",author); printf("\n");}return head_book;}struct book *Search_Book_bianhao(int bianhao,struct book *head_book) {struct book *ptr_book; int flag=0;for(ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next){if(ptr_book->bianhao==bianhao){printf("图书编号:%d\n",ptr_book->bianhao);printf("图书名称:%s\n",ptr_book->book_name);printf("图书单价:%.2lf\n",ptr_book->price);printf("存在状态:%s\n",ptr_book->state);printf("借书人姓名:%s\n",ptr_book->name);printf("借书人性别:%s\n",ptr_book->sex);printf("学号:%d\n",ptr_book->xuehao);printf("\n"); flag++;}}if(flag==0){printf("暂无此图书信息!\n\n"); }return head_book;}struct book *Search_Book_name(char *b_name,struct book *head_book){struct book *ptr_book;int flag=0;for(ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next){if(strcmp(ptr_book->book_name,b_name)==0){printf("图书编号:%d\n",ptr_book->bianhao);printf("图书名称:%s\n",ptr_book->book_name);printf("图书单价:%.2lf\n",ptr_book->price);printf("图书作者:%s\n",ptr_book->author);printf("存在状态:%s\n",ptr_book->state);printf("借书人姓名:%s\n",ptr_book->name);printf("借书人性别:%s\n",ptr_book->sex);printf("学号:%d\n",ptr_book->xuehao);printf("\n");flag++;}}if(flag==0){printf("暂无此图书信息!\n\n"); }return head_book;}struct book *Search_Book_price(double price_h,double price_l,struct book *head_book){struct book *ptr_book;int flag=0;for(ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next){if((ptr_book->price>=price_l)&&(ptr_book->price<=price_h)){printf("图书编号:%d\n",ptr_book->bianhao);printf("图书名称:%s\n",ptr_book->book_name);printf("图书单价:%.2lf\n",ptr_book->price);printf("图书作者:%s\n",ptr_book->author);printf("借书人姓名:%s\n",ptr_book->name);printf("借书人性别:%s\n",ptr_book->sex);printf("学号:%d\n",ptr_book->xuehao);printf("\n");flag++;}}if(flag==0){printf("暂无此图书信息!\n\n"); }return head_book;}struct book *Delete_Book(struct book *head_book,int bianhao) {struct book *ptr1_book,*ptr2_book;while(head_book!=NULL && head_book->bianhao==bianhao){ptr2_book=head_book;head_book=head_book->book_next;free(ptr2_book);}if(head_book==NULL) return NULL;ptr1_book=head_book;ptr2_book=head_book->book_next;while(ptr2_book!=NULL){if(ptr2_book->bianhao==bianhao){ptr1_book->book_next=ptr2_book->book_next;free(ptr2_book);}elseptr1_book=ptr2_book;ptr2_book=ptr1_book->book_next;}return head_book;}struct club *Create_New_Club(){struct club *head_club,*p_club;int xuehao;char name[20],sex[10];int size_club=sizeof(struct club);head_club=NULL;printf("请输入会员名字:");scanf("%s",name);printf("请输入会员性别:");scanf("%s",sex);printf("请输入会员学号:"); scanf("%d",&xuehao);printf("\n");while(xuehao!=0){p_club=(struct club *)malloc(size_club);strcpy(p_club->name,name);strcpy(p_club->sex,sex);p_club->xuehao=xuehao;strcpy(p_club->borrow,"暂无");head_club=Insert_Club(head_club,p_club);printf("请输入会员名字:");scanf("%s",name);printf("请输入会员性别:");scanf("%s",sex);printf("请输入会员学号:"); scanf("%d",&xuehao);printf("\n");}return head_club;}struct club *Search_Club_xuehao(int xuehao,struct club *head_club){struct club *ptr_club;int flag=0;for(ptr_club=head_club;ptr_club;ptr_club=ptr_club->club_next){if(ptr_club->xuehao==xuehao){printf("会员姓名:%s\n",ptr_club->name);printf("会员性别:%s\n",ptr_club->sex);printf("会员学号:%d\n",ptr_club->xuehao);printf("所借图书:%s\n",ptr_club->borrow);printf("\n"); flag++;}}if(flag==0){printf("此用户不存在!\n\n"); }return head_club;}struct club *Search_Club_name(char *c_name,struct club *head_club){struct club *ptr_club; int flag=0;for(ptr_club=head_club;ptr_club;ptr_club=ptr_club->club_next){if(strcmp(ptr_club->name,c_name)==0){printf("会员姓名:%s\n",ptr_club->name);printf("会员性别:%s\n",ptr_club->sex);printf("会员学号:%d\n",ptr_club->xuehao);printf("所借图书:%s\n",ptr_club->borrow);printf("\n"); flag++; }}if(flag==0){ printf("此用户不存在!\n\n"); }return head_club;}struct book *Lent_Book(int bianhao,int xuehao,struct book *head_book,structclub *head_club){struct book *ptr_book;struct club *ptr_club;int flag=0;for(ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next)for(ptr_club=head_club;ptr_club;ptr_club=ptr_club->club_next){if((ptr_book->bianhao==bianhao)&&(ptr_club->xuehao==xuehao)){strcpy(ptr_book->name,ptr_club->name); /*字符串的复制,把右边的内容复制到左边*/strcpy(ptr_book->sex,ptr_club->sex);ptr_book->xuehao=ptr_club->xuehao;strcpy(ptr_book->state,"暂无");strcpy(ptr_club->borrow,ptr_book->book_name); flag++; }if(flag==0){printf("暂无此图书或您还未注册为会员!\n\n"); }}return head_book;}struct book *back(int bianhao,int xuehao,struct book *head_book,struct club *head_club){struct book *ptr_book; struct club *ptr_club;int flag=0;for(ptr_book=head_book;ptr_book;ptr_book=ptr_book->book_next)for(ptr_club=head_club;ptr_club;ptr_club=ptr_club->club_next){if((ptr_book->bianhao==bianhao) && (ptr_club->xuehao==xuehao)){strcpy(ptr_book->name,"暂无"); strcpy(ptr_book->sex,"待定");ptr_book->xuehao=0;strcpy(ptr_book->state,"暂无");strcpy(ptr_club->borrow,"暂无");flag++; }if(flag==0){ printf("输入有误,请重试\n\n"); }}return head_book;}struct book *Insert_Book(struct book *head_book,struct book *stud_book) {struct book *ptr_b,*ptr1_b,*ptr2_b;ptr2_b=head_book; ptr_b=stud_book;if(head_book==NULL){head_book=ptr_b;head_book->book_next=NULL;}else{while((ptr_b->bianhao > ptr2_b->bianhao) && (ptr2_b->book_next!=NULL)){ptr1_b=ptr2_b; ptr2_b=ptr2_b->book_next;}if(ptr_b->bianhao <= ptr2_b->bianhao){if(head_book==ptr2_b) head_book=ptr_b;else ptr1_b->book_next=ptr_b;ptr_b->book_next=ptr2_b;}else{ptr2_b->book_next=ptr_b;ptr_b->book_next=NULL;}}return head_book;}struct club *Insert_Club(struct club *head_club,struct club *stud_club) {struct club *ptr_c,*ptr1_c,*ptr2_c;ptr2_c=head_club; ptr_c=stud_club;if(head_club==NULL){head_club=ptr_c;head_club->club_next=NULL;}else{while((ptr_c->xuehao > ptr2_c->xuehao) && (ptr2_c->club_next!=NULL)){ ptr1_c=ptr2_c; ptr2_c=ptr2_c->club_next;}if(ptr_c->xuehao <= ptr2_c->xuehao){if(head_club==ptr2_c) head_club=ptr_c;else ptr1_c->club_next=ptr_c;ptr_c->club_next=ptr2_c;}else{ptr2_c->club_next=ptr_c;ptr_c->club_next=NULL;}}return head_club;}void Print_Club(struct club *head_club){struct club *ptr_c;if(head_club==NULL){printf("\n无记录\n\n");return;}printf("\n会员姓名\t会员性别\t会员学号\n\n");for(ptr_c=head_club;ptr_c;ptr_c=ptr_c->club_next)printf("%s\t\t%s\t\t%d\n",ptr_c->name,ptr_c->sex,ptr_c->xuehao);}struct club *Delete_Club(struct club *head_club,int xuehao){struct club *ptr1_club,*ptr2_club;while(head_club!=NULL && head_club->xuehao==xuehao){ptr2_club=head_club; head_club=head_club->club_next;free(ptr2_club);}if(head_club==NULL) return NULL;ptr1_club=head_club; ptr2_club=head_club->club_next;while(ptr2_club!=NULL){if(ptr2_club->xuehao==xuehao){ptr1_club->club_next=ptr2_club->club_next;free(ptr2_club);}elseptr1_club=ptr2_club;ptr2_club=ptr1_club->club_next;}return head_club;}void Print_Book(struct book *head_book){struct book *ptr_b;if(head_book==NULL){printf("\n无记录\n\n");return;}printf("\n图书编号\t图书名称\t图书单价\t图书作者\n\n");for(ptr_b=head_book;ptr_b;ptr_b=ptr_b->book_next)printf("%d\t\t%s\t\t%.2lf\t\t%s\n\n",ptr_b->bianhao,ptr_b->book_name,ptr_b->price,ptr_b->author);}。
C语言实现图书管理系统这篇文章主要为大家详细介绍了C语言实现图书管理系统,具有一定的参考价值,感兴趣的小伙伴们可以参考一下:目前为止跟着学校进度学习C语言大概半年左右,基础学习只学到了指针,学得非常浅。
说实话,起初对C语言的印象———只是一个学习计算机语言的敲门砖,对具体C语言如何应用等,非常迷茫。
直到大一下半学期的高级语言设计课程之后,试过dos运行的图形化界面的完整小程序,才发现C语言的魅力。
ok,废话不多说了,下面是我第二节课的作品————C语言的图书管理系统。
一个简单的小程序。
并非纯原创,是基于网络搜索到的“学生管理系统”改编而成的。
通过直接浏览、修改一个完整的代码,我的收获颇丰。
我认为这样比枯燥的学习代码更加高效、易懂、易记。
以下是几个我在修改程序时学到的对于我来说比较有用的几点:(这些可能很简单,但是我之前真的没学过(⊙﹏⊙)b )1.DOS界面的颜色设置(背景、字体颜色)color [attr]下面是颜色代码:(如color fc 为亮白色产生亮红色,第一个背景,第二个前景)0 = 黑色8 = 灰色1 = 蓝色9 = 淡蓝色2 = 绿色A = 淡绿色3 = 湖蓝色B = 淡浅绿色4 = 红色C = 淡红色5 = 紫色D = 淡紫色6 = 黄色E = 淡黄色7 = 白色F = 亮白色dos只能显示这几种基础颜色并不能自己定制其他的颜色2.字符串的比较(用于密码验证等)strcmp 是一个比较字符串的函数原型:extern int strcmp(char *s1,char * s2); 用法:#include <string.h> 功能:比较字符串s1和s2。
说明:当s1<s2时,返回值<0 当s1=s2时,返回值=0 当s1>s2时,返回值>03.C语言的文件操作定义一个代表文件的符号(指针变量)这样的形式FILE *fp打开文件的语句是fopen(文件位置,打开模式);文件位置好理解,就是文件所在的位置,例如D://test.txt打开模式有几种,r(read): 读w(write): 写a(append): 追加t(text): 文本文件,可省略不写b(banary): 二进制文件+: 读和写一般是rt+,也可以写成r+,和w+,就是读和写,能保留原来的内容。
山东大学威海分校机电与信息工程学院课题名称:图书销售管理系统学号:200900800355姓名:苏清江1、实验题目:图书销售管理系统2、实验要求:图书信息包括:序号、书名、作者、出版单位、价格。
试设计一图书销售管理系统,使之能提供以下功能:1、系统以菜单方式工作2、图书信息录入功能(图书信息用文件保存)--输入3、图书信息的删除与修改功能4、图书信息浏览功能--输出5、查询功能--算法:按书名/作者查询6、排序功能--算法按书名排序按价格排序7、图书购买功能:统计选购图书的总价,给出清单,屏幕输出参考以下的实际购书单(供参考,输出样式可自行设计):3.运行环境:vc6.04.主要程序代码及设计思路:4.1.主界面设计思路:主界面设计要能调用其他函数的运行、实现选择和输出功能。
我使用switch函数通过scanf输入变量实现选择功能,系统主界面要能够返回,因此我用do….while循环实现。
当选择退出时退出系统关闭软件。
代码:#include"界面1.h"void main(){ int a;do{printf(" \n\n\n*********************************图书管理系统********************************* ");printf("\n\n\t\t1.信息录入\t2.信息检索\t3.信息删除\n\n\n\t\t4.信息修改\t5.图书购买\t6.图书排序\n\n\n\t\t\t\t7.退出系统");printf("\n\n\n****************************************************************************** ");printf("\n\n\t\t\t\t请输入相关选项");scanf("%d",&a);system("cls");switch(a){case 1 :a1(); printf("\n按任意键返回主菜单");getch();system("cls");break;case 2 :a2();printf("\n按任意键返回主菜单");getch();system("cls"); break;case 3 :a3();printf("\n按任意键返回主菜单");getch();system("cls"); break;case 4 :a4();printf("\n按任意键返回主菜单");getch();system("cls"); break;case 5 :a5(); printf("\n按任意键返回主菜单");getch();system("cls");break;case 6 :a6();printf("\n按任意键返回主菜单");getch();system("cls");break;case 7 :a7();getch();break;default:a8();printf("\n按任意键返回主菜单");getch();system("cls");break;}4.2.信息录入设计思路:通过主菜单进入录入函数。
图书管理系统/*图书数据由编号、书名、出版社、单价和图书状态(库存用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语言进行文件操作和绘图应用的编程技术水平;初步了解软件开发的一般方法和步骤;提高撰写技术文档的能力。
二、详细设计2.1、数据结构链表是线形表的一种,线形表分为顺序存储结构和链式存储结构。
线形表的顺序存储结构的特点是逻辑关系上相邻的两个元素物理位置上也相邻,因此可以随机存取表中任一元素。
链式存储结构的特点是用一组任意的存储单元存储线形表的数据元素。
链表的最大的优点是对表的添加、删除、查找、排序等操作比较方便,因此采用链表来存储学生相关信息。
且对结点的定义如下://图书的数据结构:struct book{int booknum; //书号char bookname[20]; //书名char bookcreat[10]; //书的作者int turefalse; //用于借书和还书模块判断一本书是否借出的条件}book[1000]; //定义一个比较大的1000本书//会员卡的数据类型struct car{int carnum; //卡号char studentsex[4]; //性别char studentname[20]; //姓名int studentclass; //所在班级}car[1000]; //定义一千个会员//定义学生类型,用于存放借出的书籍struct student{int carnum; //卡号char lendbook[10]; //借出的书数}student[1000]; //定义一千个学生2.2总体模块图图2.2主体模块图功能说明:查询图书用于查找存储的图书信息借阅图书用于借阅存储的图书管理图书可用于对图书的增加,删除,统计和修改并对会员进行管理会员管理系统能对会员进行增加,删除和借阅统计部分模块间关系:经过管理系统对图书的处理,查询图书和借阅图书的功能才能得以实现经过会员管理系统的处理,才能实现对会员的查询和统计2.3总体流程图主函数是程序入口,采用模块化设计。
图书借阅管理系统1.课程设计的目的我这次做的系统是图书借阅管理系统,主要目的是利用本系统来管理图书的借阅问题,以实现图书借阅的快捷化、规范化、自动化来提高工作效率。
系统以实用性,通用、开放和安全的原则。
使用数据库开发软件开发制作,实现了图书借阅信息的管理,借阅图书的信息自动化添加,借阅者的个人基本信息,借阅的基本信息,对各种图书的分类管理以及各种新书的添加等一些繁琐事项。
更好的管理好图书的借阅问题。
大大的减少了人工的工作量,比以往很大程度上提高了工作人员的工作效率。
使之成为图书馆的一个平台,成为真正的现代化科技。
为了充分利用学院现有的计算机硬件资源,做好图书借阅管理工作,提高办事效率, 实现全面的、相对集中的办公自动化,开发本系统就成了当务之急,其目的主要为了彻底改变这种繁杂的管理模式,实现全面的、相对集中的、智能化的信息综合管理,为图书馆的管理工作带来方便。
我想借本次课程设计之际,开发一个适用于通用大规模图书馆的管理系统,采用现学习的C++6. 0开发工具开发出来的基于Windows系列的图书借阅管理系统。
该系统面向所有的在校学生,实现对学生个人的借书、学生的基本信息情况等的计算机管理。
系统支持工作人员对学生图书借阅信息、图书馆新书的添加、旧书的信息修改、删除等操作,确保了数据库的安全性快捷性和一致性。
2.设计方案论证2.1主界面设计思路本次设计这个系统利用于图书馆的图书借阅管理,该系统相比以往人工的记录方式减少了很多不比要得麻烦,大大的提高了图书馆工作人员的工作效率。
这次系统的开发制作主要包括以下几个方面。
书籍统计可以查询图书的名称、作者、序号等信息,以及是否借出去了。
书籍管理可以把新书添加到系统当中,修改书籍的详细资料等。
注册会员功能,借阅书籍的学生必须注册会员才可以借书,通过注册会员来添加该学生的基本信息。
通过系统来办理借书手续以记录该学生的借书信息。
学生借书模块能够查询借阅学生的信息和该学生的借书的信息。
图书管理系统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 图书查询我们可以根据图书的不同字段来实现不同的查询功能,比如根据图书标题、作者、分类等进行模糊查询,或根据图书编号进行精确查询。
#include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct link{char number[100];char bookname[100];char author[100];char publish[100];char time[100];char status[100];float price;struct link *next;}link;link *Cbook();void mainmenu();void menu1();void glmenu();void cxmenu();void jhmenu();void print(link*head);void hold(link*head);void holdcx(link*t);link *findnumber(link*head); link *findbookname(link*head); link *findauthor(link*head); link *add(link*head);link *sortnumber(link*head); link *delbook(link*head);link *revamp(link*head);link *borrowbook(link*head); link *returnbook(link*head); int main(){int a,b,c,d,e;link *h,*t;L:system("cls"); mainmenu();while(1){scanf("%d",&a);switch(a){case 1:{B:system("cls");menu1();while(1){scanf("%d",&b);switch(b){case 1:{h=Cbook();}break;case 2:{system("cls");glmenu();while(1){scanf("%d",&c);switch(c){case 1:{print(h);}break;case 2:{h=add(h);h=sortnumber(h);print(h);}break;case 3:{revamp(h);}break;case 4:{h=delbook(h);print(h);}break;case 5:{hold(h);}break;case 6:{goto B;}break;}}}break;case 3:{system("cls");cxmenu();while(1){scanf("%d",&d);switch(d){case 1:{print(h);}break;case 2:{t=findnumber(h);if(t==NULL)printf("抱歉,没有找到您要查询的图书!");else{printf("您想要查询的为:");printf("\n");printf("\n**********************************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");printf("\n");printf("%s\t%s\t%s\t%s\t%s\t",t->number,t->bookname,t->author,t->publish,t->time);printf("\t\t%.2f",t->price);printf("\t\t%s",t->status);}}break;case 3:{t=findbookname(h);if(t=NULL)printf("抱歉,没有找到您要查询的图书!");else{printf("您要查询的图书为:");printf("\n");printf("\n**********************************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");printf("\n");printf("%s\t%s\t%s\t%s\t%s\t",t->number,t->bookname,t->author,t->publish,t->time);printf("\t\t%.2f",t->price);printf("\t\t%s",t->status);}}break;case 4:{t=findauthor(h);if(t=NULL)printf("抱歉,没有找到您要查询的图书!");else{printf("您要查询的图书为:");printf("\n");printf("\n**********************************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");printf("\n");printf("%s\t%s\t%s\t%s\t%s\t",t->number,t->bookname,t->author,t->publish,t->time);printf("\t\t%.2f",t->price);printf("\t\t%s",t->status);}}break;case 5:{holdcx(t);}break;case 6:{goto B;}break;}}}break;case 4:{system("cls");jhmenu();while(1){scanf("%d",&e);switch(e){case 1:{borrowbook(h);}break;case 2:{returnbook(h);}break;case 3:{goto B;}break;}}break;case 5:{hold(h);}break;case 6:{system("cls");menu1();}break;case 7:{goto L;}break;}}}break;case 0:{printf("\t\t\t感谢您的使用,再见!");exit(0);};}}return 0;}}link *Cbook(){int n=0;link *p,*q,*head;FILE *fp;fp=fopen("图书信息.txt","r+");if(fp==NULL)printf("没有找到文件,请检查......");p=(link *)malloc(sizeof(link));if(p==NULL)printf("申请内存出错!\n");fscanf(fp,"%s%s%s%s%s",p->number,p->bookname,p->author,p->publish,p->time);fscanf(fp,"%f",&p->price);fscanf(fp,"%s",p->status);while(feof(fp)==0){n++;if(n==1){head=p;}else{q=p;p=(link *)malloc(sizeof(link));if(p==NULL)printf("申请内存出错!\n");fscanf(fp,"%s%s%s%s%s",p->number,p->bookname,p->author,p->publish,p->time);fscanf(fp,"%f",&p->price);fscanf(fp,"%s",p->status);q->next=p;}}p->next=NULL;fclose(fp);printf("信息已录入!");return head;}void mainmenu(){printf("\n*****************************************\n");printf("\n 欢迎使用图书管理系统\n");printf("\n 1.进入系统\n");printf("\n 0.退出系统\n");printf("\n*****************************************\n");printf("\n请选择:");}void menu1(){printf("\n*****************************************\n");printf("\n 1.录入所有图书信息\n");printf("\n 2.进入图书管理系统\n");printf("\n 3.进入图书查询系统\n");printf("\n 4.进入图书借还系统\n");printf("\n 5.保存所有图书信息\n");printf("\n 6.显示菜单\n");printf("\n 7.返回上级菜单\n");printf("\n*****************************************\n");printf("请选择:");}void glmenu(){printf("\n*****************************************\n");printf("\n 1.显示所有图书信息\n");printf("\n 2.添加一本图书信息\n");printf("\n 3.修改一本图书信息\n");printf("\n 4.删除一本图书信息\n");printf("\n 5.保存所有图书信息\n");printf("\n 6.返回上级菜单\n");printf("\n*****************************************\n");printf("请选择:");}void cxmenu(){printf("\n*****************************************\n");printf("\n 1.显示所有图书信息\n");printf("\n 2.按编号查询图书\n");printf("\n 3.按书名查询图书\n");printf("\n 4.按作者查询图书\n");printf("\n 5.保存所查询图书信息\n");printf("\n 6.返回上级菜单\n");printf("\n*****************************************\n");printf("请选择:");}void jhmenu(){printf("\n*****************************************\n");printf("\n 1.借书\n");printf("\n 2.还书\n");printf("\n 3.返回上级菜单\n");printf("\n*****************************************\n");printf("请选择:");}void print(link *head){link *p;p=head;if(p==NULL){printf("文件中没有图书信息\n");}else{printf("\n");printf("\n*****************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");while(p!=NULL){printf("\n");printf("%s\t\t%s\t\t%s\t\t%s\t\t%s",p->number,p->bookname,p->author,p->publish,p->time);printf("\t\t%.2f",p->price);printf("\t\t%s",p->status);printf("\n");p=p->next;}}}void hold(link *head){link *p;FILE *fp;fp=fopen("图书信息.txt","w+");if(fp==NULL){printf("文件操作出错!");exit(1);}p=head;for(;p!=NULL;p->next){fprintf(fp,"\n");fprintf(fp,"%s\t\t%s\t\t%s\t\t%s\t\t%s",p->number,p->bookname,p->author,p->publish,p->t ime);fprintf(fp,"\t\t%.2f",p->price);fprintf(fp,"\t\t%s",p->status);}fclose(fp);printf("信息已保存!");}void holdcx(link *t){link *p=NULL;FILE *fp;fp=fopen("查询.txt","a+");p=t;fprintf(fp,"查询到的信息为:\n");fprintf(fp,"\n");fprintf(fp,"\n*****************************************\n");fprintf(fp,"\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");fprintf(fp,"\n");fprintf(fp,"%s\t\t%s\t\t%s\t\t%s\t\t%s",p->number,p->bookname,p->author,p->publish,p->t ime);fprintf(fp,"\t\t%.2f",p->price);fprintf(fp,"\t\t%s",p->status);fprintf(fp,"\n");fclose(fp);printf("信息已保存!");}link *findnumber(link *head){char key[100];link *h,*t1=NULL;printf("请输入图书的编号:");getchar();gets(key);for(h=head;h!=NULL;h=h->next){if(strcmp(key,h->number)==0){t1=h;break;}}return t1;}link *findbookname(link *head){char key[100];link *h,*t2=NULL;printf("请输入图书的书名:");getchar();gets(key);for(h=head;h!=NULL;h=h->next){if(strcmp(key,h->bookname)==0){t2=h;break;}}return t2;}link *findauthor(link *head){char key[100];link *h,*t3=NULL;printf("请输入作者姓名:");getchar();gets(key);for(h=head;h!=NULL;h=h->next){if(strcmp(key,h->author)==0){t3=h;break;}}return t3;}link *add(link *head){link *h,*h1;h1=head;h=(link *)malloc(sizeof(link));if(h==NULL){printf("申请内存出错!");exit(1);}printf("请输入添加图书的信息:");printf("\n");printf("\n*****************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");printf("\n");scanf("%s\t\t%s\t\t%s\t\t%s\t\t%s",h->number,h->bookname,h->author,h->publish,h->time );scanf("\t\t%f",&h->price);scanf("\t\t%s",h->status);h->next=h1;return h;}link *sortnumber(link *head){link *p,*q,*temp;temp=(link *)malloc(sizeof(link));if(temp==NULL){printf("申请内存出错!");exit(1);}for(p=head;p!=NULL;p=p->next){for(q=p->next;q!=NULL;q=q->next){if(strcmp(p->number,q->number)>0){strcpy(temp->number,p->number);strcpy(temp->bookname,p->bookname);strcpy(temp->author,p->author);strcpy(temp->publish,p->publish);strcpy(temp->time,p->time);temp->price=p->price;strcpy(temp->status,p->status);strcpy(p->number,q->number);strcpy(p->bookname,q->bookname);strcpy(p->author,q->author);strcpy(p->publish,q->publish);strcpy(p->time,q->time);p->price=q->price;strcpy(p->status,q->status);strcpy(q->number,temp->number);strcpy(q->bookname,temp->bookname);strcpy(q->author,temp->author);strcpy(q->publish,temp->publish);strcpy(q->time,temp->time);q->price=temp->price;strcpy(q->status,temp->status);}}}return head;}link *delbook(link *head){int k=0;char str[10];link *h,*t,*p;h=t=p=head;printf("请输入要删除的图书名:");getchar();gets(str);for(;p!=NULL;p->next){k++;if(k>2){t=t->next;}if((strcmp(p->bookname,str)==0)&&(k=1)){h=p->next;}else if(strcmp(p->bookname,str)==0&&k>1){t->next=p->next;}else if(strcmp(p->bookname,str)==0&&p->next==NULL){t=NULL;}}return h;}link *revamp(link *head){link *h,*t;h=head;t=findbookname(h);if(t==NULL)printf("没有找到.......");else{printf("修改前图书信息为:");printf("\n");printf("\n*****************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");printf("\n");printf("%s\t\t%s\t\t%s\t\t%s\t\t%s",t->number,t->bookname,t->author,t->publish,t->time);printf("\t\t%.2f",t->price);printf("\t\t%s",t->status);printf("\n");}printf("请输入这本书(书名除外)所有信息:\n");printf("\n*****************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");printf("\n");scanf("%s\t\t%s\t\t%s\t\t%s\t\t%s",t->number,t->bookname,t->author,t->publish,t->time);scanf("\t\t%2f",&t->price);scanf("\t\t%s",t->status);printf("修改后图书信息为:\n");printf("\n");printf("\n*****************************************\n");printf("\n编号\t\t书名\t\t作者\t\t出版社\t\t出版时间\t\t价格\t\t状态\n");printf("\n");printf("%s\t\t%s\t\t%s\t\t%s\t\t%s",t->number,t->bookname,t->author,t->publish,t->time);printf("\t\t%.2f",t->price);printf("\t\t%s",t->status);printf("\n");return head;}link *borrowbook(link *head){link *h,*p;char ch,ch1[100]="在库",ch2[100]="不在库";h=head;printf("\n*****************************************\n");printf("欢迎使用借书系统!\n");p=findbookname(h);if(p==NULL)printf("借书失败,书库中没有这本书!");else if(strcmp(p->status,ch2)==0)printf("借书失败,书库中没有这本书!");else{printf("确认借出?Y/N:");scanf("%c",&ch);getchar();if(ch=='Y'||ch=='y'){strcpy(p->status,ch2);printf("借书成功,请返回上级菜单保存信息!");}if(ch=='N'||ch=='n'){printf("你没有借任何书!");}}return head;}link *returnbook(link *head){link *h,*p;char ch,ch1[100]="在库",ch2[100]="不在库";h=head;printf("\n*****************************************\n");printf("欢迎使用还书系统!\n");p=findbookname(h);if(p==NULL)printf("还书失败,这不是本库的书!");else{printf("确认还书?Y/N:");scanf("%c",&ch);getchar();if(ch=='Y'||ch=='y'){strcpy(p->status,ch1);printf("还书成功,请返回上级菜单保存信息!");}if(ch=='N'||ch=='n'){printf("你没有还书!");}}return head;}。