C--课程设计图书管理.doc
成绩:实 验 报 告课程名称:C+课程设计实验项目:图书管理姓 名:专 业:计算机科学与技术班 级:学 号:计算机科学与技术学院20 16 年 3 月 10 日 实验报告实验项目名称: 图书管理 一、设计目的设计一个可操作的图书管理系统二、课程设计内容图书类有书号 书名 作者 现有数量 借出数量这5个属性读者类有账号 密码 借的书 借的书数量这4个属性图书馆类包含图书类对象数组,读者类对象数组,已有图书种类,已有读者数量,正在登录的用户5个属性整体分为图书和读者两大模块图书模块有初始化 图书购进两功能读者模块有注册 登陆 查找借阅 还书 查询借阅功能三、课程设计步骤进入系统首先进行图书初始化功能,本过程应由图书管理员完成图书初始化完成后清屏,进入登陆注册界面,未注册的用户应先注册再登陆。登陆成功后可进行图书查找借阅,图书归还,查看借阅信息功能四、运行结果1.图书初始化2。注册登陆3。主界面4。查阅借阅5。查询借阅信息6。还书系统7退出五 程序代码#include<cstdio>#include<iostream>#include<cstring>#include<malloc.h>#include<stdlib.h>using namespace std;#define size 20int x;int m;char t10;void change(char a,int k) printf("%sn是否修改,修改按1,返回上层按2n",ak); if(x=1) scanf("%s",ak); printf("修改成功n"); class bookpublic: char booknum10; char bookname10; char bookauthor10; int xianyou; int jiechu;class readerpublic: char readernum10; char readerkey10; book mybook3; int mybookamount; reader() mybookamount=0; ;class libraryprivate: book ebook20; int bookamount; reader ereader20; int readeramount; int loginnum;public: library() bookamount=0; readeramount=0; void showloginnum() printf(" 用户%sn",ereaderloginnum.readernum); void zhuce() printf("请输入账号:n"); scanf("%s",t); for(x=0;x<readeramount;x+) if(strcmp(t,ereaderx.readernum)=0) printf("账号已被注册请重新输入n"); scanf("%s",t); x=-1; continue; readeramount+; strcpy(ereaderreaderamount-1.readernum,t); strcpy(t,""); printf("请输入密码:n"); scanf("%s",t); strcpy(ereaderreaderamount-1.readerkey,t); printf("注册成功n"); void xxx() for(x=0;x<readeramount;x+) printf("ereader%d.readernum= %s n",x,ereaderx.readernum); printf("ereader%d.readerkey= %s n",x,ereaderx.readerkey); void login() strcpy(t,""); printf("请输入账号:n"); scanf("%s",t); for(x=0;x<readeramount;x+) if(strcmp(t,ereaderx.readernum)=0) printf("strcom=%dn",strcmp(t,ereaderx.readernum); break; printf("x=%dnreaderamount=%dn",x,readeramount); if(x=readeramount+1) printf("该账号未注册,按任意键回车返回主菜单n"); scanf("%s",t); else strcpy(t,""); printf("请输入密码:n"); scanf("%s",t); if(strcmp(t,ereaderx.readerkey)=0) printf("登陆成功n"); loginnum=x; else printf("密码错误,按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); void lookandborrow() printf("书号查找请按1 书名查找请按2 作者查找请按3n"); scanf("%d",&m); if(m=1) printf("请输入书号:n"); scanf("%s",t); for(x=0;x<bookamount;x+) if(strcmp(t,ebookx.booknum)=0) printf("书号 书名 作者 现有数量 借出数量n"); printf("%s %s %s %d %dn",ebookx.booknum,ebookx.bookname,ebookx.bookauthor,ebookx.xianyou,ebookx.jiechu); printf("是否借出? 借出请按1 否请按2n"); scanf("%d",&m); if(m=1) ereaderloginnum.mybookereaderloginnum.mybookamount=ebookx; ebookx.xianyou-; ebookx.jiechu+; ereaderloginnum.mybookamount+; printf("借出成功n"); printf("按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); system("cls"); break; if(m=2) printf("按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); system("cls"); break; if(m=2) printf("请输入书名:n"); scanf("%s",t); for(x=0;x<bookamount;x+) if(strcmp(t,ebookx.bookname)=0) printf("书号 书名 作者 现有数量 借出数量n"); printf("%s %s %s %d %dn",ebookx.booknum,ebookx.bookname,ebookx.bookauthor,ebookx.xianyou,ebookx.jiechu); printf("是否借出? 借出请按1 否请按2n"); scanf("%d",&m); if(m=1) ereaderloginnum.mybookereaderloginnum.mybookamount=ebookx; ebookx.xianyou-; ebookx.jiechu+; ereaderloginnum.mybookamount+; printf("借出成功n"); printf("按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); system("cls"); break; if(m=2) printf("按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); system("cls"); break; if(m=3) printf("请输入作者:n"); scanf("%s",t); for(x=0;x<bookamount;x+) if(strcmp(t,ebookx.bookauthor)=0) printf("书号 书名 作者 现有数量 借出数量n"); printf("%s %s %s %d %dn",ebookx.booknum,ebookx.bookname,ebookx.bookauthor,ebookx.xianyou,ebookx.jiechu); printf("是否借出? 借出请按1 否请按2n"); scanf("%d",&m); if(m=1) ereaderloginnum.mybookereaderloginnum.mybookamount=ebookx; ebookx.xianyou-; ebookx.jiechu+; ereaderloginnum.mybookamount+; printf("借出成功n"); printf("按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); system("cls"); break; if(m=2) printf("按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); system("cls"); break; void show() for(x=0;x<ereaderloginnum.mybookamount;x+) printf("书号 :%sn",ereaderloginnum.mybookx.booknum); printf("书名 :%sn",ereaderloginnum.mybookx.bookname); printf("作者 :%sn",ereaderloginnum.mybookx.bookauthor); printf("按任意键回车返回主菜单n"); scanf("%s",t); strcpy(t,""); system("cls"); void comeback() printf("请输入要归还的书的书号:n"); scanf("%s",t); for(x=0;x<=ereaderloginnum.mybookamount;x+) if(strcmp(ereaderloginnum.mybookx.booknum,t)=0) strcpy(ereaderloginnum.mybookx.booknum,""); strcpy(ereaderloginnum.mybookx.bookname,""); strcpy(ereaderloginnum.mybookx.bookauthor,""); ereaderloginnum.mybookx.xianyou=0; ereaderloginnum.mybookx.jiechu=0; ereaderloginnum.mybookamount-; for(x=0;x<bookamount;x+) if(strcmp(ebookx.booknum,t)=0) ebookx.jiechu-; ebookx.xianyou+; system("cls"); printf("还书成功n"); void booksign() printf("图书初始登记n"); while(1) printf("请输入书号:n"); scanf("%s",ebookbookamount.booknum); printf("请输入书名:n"); scanf("%s",ebookbookamount.bookname); printf("请输入作者:n"); scanf("%s",ebookbookamount.bookauthor); printf("请输入图书数量:n"); scanf("%d",&ebookbookamount.xianyou); ebookbookamount.jiechu=0; bookamount+; printf("是否继续登记?是请按1 否请按2n"); scanf("%d",&m); if(m=1); if(m=2) break; system("cls"); printf("初始化完毕n"); void income() printf("图书增添系统n"); while(1) printf("请输入书号:n"); scanf("%s",ebookbookamount.booknum); printf("请输入书名:n"); scanf("%s",ebookbookamount.bookname); printf("请输入作者:n"); scanf("%s",ebookbookamount.bookauthor); printf("请输入图书数量:n"); scanf("%d",&ebookbookamount.xianyou); ebookbookamount.jiechu=0; bookamount+; printf("是否继续登记?是请按1 否请按2n"); scanf("%d",&m); if(m=1); if(m=2) break; system("cls"); printf("增添完毕n"); ;void menu(library &l) while(1) printf(" -n"); printf(" -n"); printf(" | 图 书 管 理 系 统 |n"); printf(" -n"); printf(" -n"); l.showloginnum(); printf("1 进书登记n"); /printf("2 读者注册n"); /printf("3 读者登录n"); printf("2 查阅借阅n"); printf("3 还书系统n"); printf("4 查询已借书目n"); printf("0 退出n"); printf("nnn请输入数字n"); scanf("%d",&m); if(m=1) l.income(); if(m=2) l.lookandborrow(); if(m=3) eback(); if(m=4) l.show(); if(m=0) break; int main() library chuantuo; chuantuo.booksign(); printf(" -n"); printf(" -n"); printf(" | 图 书 管 理 系 统 |n"); printf(" -n"); printf(" -n"); printf("登录请按1 注册请按2n"); scanf("%d",&m); if(m=1) chuantuo.login(); if(m=2) chuantuo.zhuce(); printf("正在登陆n"); /chuantuo.xxx(); chuantuo.login(); system("cls"); menu(chuantuo); printf("再见n");