可按Ctrl+D收藏 蚂蚁资源网

蚂蚁资源网

图书管理系统源码(图书信息管理系统代码)

  • 全部评论(3)
  • gyq
  • / ************************************************* * ************************************************* ************ /#包括 #include #include #include //使用命名空间std输入/输出文件流; const int maxr = 100; //大多数读者const int maxb = 100; // Upli Book Const金额= 5 //每个读者借用了五本书//阅读器类,实现了读者信息类阅读器的描述{私有:int标签; //删除标签1:已删除0:未选择的INT NO; //阅读器号char名[10]; //读者int borbook [maxbor]的名称; //公共由书籍:e69da5e887aa62616964757a686964616f31333335333666Reader(){}字符*的getName(){返回名称;} //获取名称int gettag(){返回标签; } //获取删除标记int getno(){返回否;} //获取读者号void setName(char na [])//设置您的姓名{struch(name,na); void delbook(){ta​​g = 1; } //设置删除标签1:删除0:没有void addreader(int n,char * na)//增加读者{tag = 0; no = n; Strcpy(名称,NA); for(int i = 0 i >选择;切换(选择){案例'1':cout << "输入读者编号:";cin >>阅读器; cout << "输入读者姓名:";cin >> rname; addreader(ReaderID,Rname);休息;案例'2' :cout << "输入读者编号:";cin >>阅读器; r =查询(readerID);如果(r == null){cout << " 该读者不存在 "<> rname; r-> setname(rname);休息;案例'3':cout << " 输入读者编号:"; cin >>阅读器; r =查询(readerID);如果(r == null){cout <<" 该读者不存在" << endl; break;}r-> delbook();休息;案例'4':cout << "读入读者编号:";cin >>阅读器; r =查询(readerID);如果(r = = null){cout <<"该读者不存在"<< endl;break;}r-> disp();休息;案例'5':disp();休息;案例'6':clear();休息;休息;默认:cout <<"输入错误,请从新输入:";break;}}}//图书类,实现对图书的描述,图书的编号,书名,借出,还入等class Book{private: int tag;//删除标记 1:已删 0:未删int no;//图书编号char name[20];//书名int onshelf;//是否再架 1:再架 2:已借public:Book(){}char *getname() { return name; }//获取姓名int getno(){ return no; }//获取图书编号int gettag(){ return tag; }//获取删除标记void setname(char na[])//设置书名{strcpy(name,na);}void delbook(){ tag=1;}//删除图书void addbook(int n,char *na)//增加图书{tag=0;no=n;strcpy(name,na);onshelf=1;}int borrowbook()//借书操作{if (onshelf==1){onshelf=0;return 1;}return 0;}void retbook()//还书操作{onshelf=1;}void disp()//输出图书{cout << setw(6) << no << setw(18) << name << setw(10)<<(onshelf==1? "在架":"已借") <>选择;开关(CONCHe){案例'1':cout << "输入图书编号:"<>书签; cout << "输入图书书名:"<> bname;附加册(Bookid,Bname);休息;案例'2':COUT << "输入图书编号:"<>书签; b =查询(Bookid); if(b == null){cout << " 该图书不存在 "<> bname; b-> setname(bname);休息;案例'3':cout <<" 读入图书编号:"<>书签; b =查询(Bookid); if(b == null){cout <<" 该图书不存在" << endl; break;}b-> delbook();休息;案例'4':cout << " 读入图书编号:"<>书签; b =查询(Bookid); if(b == null){cout <<" 该图书不存在"<< endl;break;}b-> disp();休息;案例'5':DISP();休息;案例'6':clear();休息;默认值:cout <<"输入错误,请从新输入:";}}}//main() 函数的实现,程序的主界面的引导int main(void){ char choice;int bookid,readerid;RDatabase ReaderDB;Reader *r;BDatabase BookDB;Book *b;while(choice!='0'){ cout <>选择;切换(选择){COPY'1':COUT <<" 借书 读者编号:";cin >>阅读器; cout <<" 图书编号: ";cin >>书签; r = readerdb.query(ReaderID); //查找if(null == r){cout <<" 不存在该读者,不能借书"<< endl;break;}b=BookDB.query(bookid);if (b==NULL){cout <<" 不存在该图书,不能借书"<< endl;break;}if (b->借款()== 0){cout << " 该图书已借出,不能借书"<< endl;break;}r->借贷(b-> getno());休息;案例'2':cout <<"还书\n 读者编号:";cin >>阅读器; cout << " 图书编号:";cin >>书签; r = readerdb.query(ReaderID); if(r == null){cout <<" 不存在该读者,不能还书" << endl;break;}b=BookDB.query(bookid);if (b==NULL){cout <<" 不存在该图书,不能还书" < Retby(); R-> RET.书(B-> getno());休息;案例'3':BookdB.BookData();休息;案例'4':ReaderDB.ReaderData();休息;默认值:COUT <<“输入错误,请从新输入:”}}返回0;我希望解决您的问题。
  • 2021-09-08 18:16:42
  • 电竞比分源码专营
  • 展开所有#include#包含#include#define n 100 // book的struct book {char标题[30]; int号码; Char作者[30];浮价; int store; char borrower_name [20]; Char Borrower_Gender [5]; int borrower_number;} s [n]; int m = 0; void输入(Structbook * P); //输入书信息禁止保存(Structbook * P); //保存书籍信息void读取(StructBook * P); //阅读书信息void搜索; //查找书信息void del(Structbook * P); //删除书籍信息void借用(StructBook * P); //借用书籍无效(StructBook * P); //返回栏void main(){int x; do {printf(“************************* ***********菜单******** ****************************** \ n“”*********** 1.输入书籍信息********** \ n“”********** 2.查找书籍信息********** \ n“”*********** 3。删除书籍信息********** \ n“”*********** 4.借书********* \ n“** *** ****** 5.退货********** \ n“”********** 0.退出********* * \ n“ ); Printf(“*********************************************** ************************************************** ************************************************** ************************************************** ************************************************** ************************************* ************* *************************** \ n“); PRINTF(”请在0 -5选择,END \ n“中输入键“); scanf(“%d”,&x);切换(x){案例1:输入(&s [0]);休息;案例2:搜索(&s 0]);休息;案例3:del(&s [0]);休息;案例4:借用(&s [0]);休息;案例5:Retur(&S [0]);休息;案例0:休息; }}} while(} void输入(结构簿* p){int y; for(; p {printf(“请输入标题:”); scanf(“%s”,p->标题)printf(“请enternumber :“); scanf(”%d“,&p-> number); printf(”请输入作者:“); scanf(”%s“,p->作者); printf(”请输入书籍价格:“); scanf(”%f“,&p->价格); printf(”请输入书籍数量:“); scanf(”%d“,&p-> store); m ++; printf (“%d信息已经完成完成后,您是否继续?\ n按任意键继续,按0按钮结束。”,m); scanf(“%d”,&y); / /阅读是否继续if(y == 0){保存(&s)[0]);读(&s [0]); //呼叫读取文件函数break;}}}}}}}}}}}}}}}}}}}}}}}}}}}} void搜索(结构簿* p) //查询模块{int n; char name1 [20]; char name2 [20]; char c [3];做{p =&s [0]; printf(“\ t请选择查找方法:\ /打印查询菜单”printf(“1.按To Book”\ n 2通过作者返回\ n 0.2); printf(“请选择:\ n \ n“在0-2中); scanf(”%d“,&n); //读取查找方法if(n == 0)中断;切换(n){case 1:printf(”请输入标题:\ n“); scanf(”%s“,name1);休息;案例2:printf(”请输入作者:\ n“); scanf(”%s“,name2); break;} for( ; p {read(&s [0]); //呼叫读取功能if(strcmp(p->标题,name1)== 0 | strcmp(p-> author,name2)== 0){printf(“ \ n查找簿信息成功!\ n“); printf(”编号id作者价格编号\ n“); printf(”% - 10s%-10d%-10s%-10.2f%-10d \ n“, p->标题,p->号码,p->作者,p->价格,p->商店); //打印信息break;}} printf(“你继续找到吗?\ n”是“类型”是“,”否“请按任意键,返回菜单\ n”); scanf(“%s”,c);} while(strcmp(c,“是”)== 0); //判断是否结束} void del(结构簿* p)//删除模块{int i; STRICT BOOK * P1,* P2; char name1 [20]; Char Name2 [20]; char c [3]; int n; do {p =&s [0]; printf(“请选择删除”; \ n“); //打印删除菜单printf(“1.按照书名删除\ n \ n 2.按作者删除\ n 0.返回\ n”); Printf(“请选择:\ n \ n”在0-2); scanf(“%d”,&n); //读取查找聚会// if(n == 0)中断switchh(n){casse 1:printf(“请输入标题:\ n”); scanf(“%s”,name1);休息;案例2:Printf(“请输入作者:\ n”); scanf(“%s”,name2);休息;读(&s [0]); //呼叫阅读for(i = 0; i {i(strcmp(p->标题,name1)== 0 || strcmp(p-> author,name2)== 0){p1 = p; for(p2 = p1 + 1 ; p2 <=&s[m];p1++,p2++) { strcpy(p1->标题,p2->标题); strcpy(p1->作者,p2->作者); p1-> number = p2-> number; p1-> store = p2->商店; p1->价格= p2->价格; m - ; printf(“删除成功!! \ n”);}} else {printf(“没有书记记录!!”); break;}} printf(“你会继续删除吗?”是“请输入”是“,”否“请按任意键,返回菜单\ n”); scanf(“%s”,c); //阅读是否继续保存(&s [0]); //呼叫保存功能}(strcmp(c,“是”)== 0); // deconstive继续删除} voidborrow(structbook * p)//借用模块{int z; char name3 [20],name4 [20] ; char w [3]; do {p =&s [0]; printf(“请找到您想要借书!”); printf(“请修理CT查找方法:\ n“); //打印查询菜单printf(”1.按标题查找\ n 2.查找\ n 0.返回\ n“由作者printf(”请选择:\ n返回\ n“在0-2); scanf(“%d”,&z); //读取查找方法if(z == 0)中断;切换(z){case 1:printf(“请输入标题:\ n “); scanf(”%s“,name3);休息;案例2:printf(”请输入作者:\ n“); scanf(”%s“,name4); break;}读(&s [0 ]); //调用(; p {if(strcmp(p->标题,name3)== 0 | strcmp(p->作者,name4)== 0 {printf(“\ n”成功! \ n“); printf(”名称编号作者价格编号\ n“); printf(”% - 10s%-10d%-10s%-10.2fs%-10d)\ n“,p->标题,p- >号码,P->作者,P->价格,P->商店); //打印信息Printf(“请输入您的姓名:”)Scanf(“%s”,p->借款台_姓名); Printf(“请输入您的性别:”); scanf(“%s”,p-> borrower_gender); Printf(“请输入您的学号:”); Scanf(“%d”,&p-> borrower_number); P->商店 - ; Printf(“借用成功!\ n”); Printf(“标题号作者”价格数量书主题性别学习\ n“); Printf(“% - 10s%-10d%-10s%-10.2f%-10d%-10s%-10s%-10d \ n”,p->标题,p->数字,p->作者,p->价格,p->博士_name,p->伯罗瑟_gender,p->伯罗瑟_number; break; printf(“继续借一本书”); printf(“是”请输入“是” ,“否”请按任意键,返回菜单\ n“); scanf(”%s“,w); //读取是否继续保存(&s [0]); //调用保存函数}(strcmp (W,“是”)== 0); //判断是否继续借书} void Retur(Structure){int e,f; Char Name5 [20]; Char Name6 [20]; char t [3]; do {p =&s [0]; printf(“请寻找您的图表!”); printf(“请选择查找模式:\ n”); //打印查询菜单printf(“1.按标题查找\ n 2.根据作者查找\ n 0.返回\ n”); Printf(“请选择:\ n \ n”在0-2); SCANF(“%D”,&E); //如果(e == 0)中断,请阅读查找方法;切换(e){案例1:printf(“请输入标题:\ n”); scanf(“%s”,name5);休息;案例2:Printf(“请输入作者:\ n”); scanf(“%s”,name6);休息;读(&s [0]); //调用(; p {if(strcmp(p->标题,name5)== 0 || strcmp(p-> author,name6)== 0){printf(“查找书信息成功!\ n“); Printf(”确认书籍应该被按下“1”!“); // Infirm仍然是一本书scanf(“%d”,&f); if(f == 1){struct(p-> borrower_name,0“); strcpy(p-> borrower_gender,“0”); p-> borrower_number = 0; P - > Store ++; Printf(“由书借来的标题书籍数量\ n”); Printf“%-10s%-10d%-10s%-10.2f%-10d%-10s%-10s%-10d \ n”,p->标题,p->数字,p->作者,p->价格,p->商店,p-> borrower_name,p-> borrower_gender,p-> borrower_number); //打印信息} break; else {printf(“没有书记!”);打破; printf(“是继续持续预订\ n]); printf(“?”是“类型”是“,”否“按任意键返回菜单\ n”); scanf(“%s”,t); //读取是继续保存(&s [0]); //调用保存函数}(strcmp(t,“是”)== 0); //判断是否持续的书籍} void保存(structbook * p)//保存文件{file * fp,* fp1; int 1; ((fp = fopen(“tushu.txt”,“wb”))== null)//打开文件并确定错误{printf(“创建文件失败!\ n \ n”); //打印错误提示getchar();返回;如果(fp1 = fopen(“book.txt”,“wb”))== null)//打开文件并确定错误是否是{printf(“创建文件失败!\ n”); //打印错误提示getchar();返回;} for(i = 0; i ix)写(p,sizeof(结构簿),1,fp)== 0)//将数据写入文件,并确定错误printf(“”\ n \ n “在文件中!\ n \ n”); FPRINTF(FP1,“%d”,m); fclose(FP); //关闭文件fclose(fp1); //关闭文件} void读取(结构簿* p)//读取信息模块{file * fp,* fp1; INT I; if((fp = fopen(“tushu.txt”,“rb”))== null)// opens文件,并确定错误{printf(“错误,请检查文件是否存在,按任意键返回直播菜单”); //打印错误提示getchar();}如果(fp1 = fopen(“book.txt”,“rb”))== null)//打开文件并确定错误{printf(“创建文件失败!\ n \ n“); //打印错误提示getchar();返回; FSCANF(FP1,“%D”,&M); fclose(FP1); //关闭文件(i = 0; i {fread(p,stizeof(结构书),1,fp; //读取信息来自文件} fclose(fp); //关闭文件}您可以修改保存的文件地址自己。希望可以帮忙
  • 2021-09-08 18:13:51
  • lyrhc
  • 有没有图书管理系统的源代码啊,#include #include #include #include #include #define STACK_INIT_SIZE 10 #define OK 1 #define TRUE 1 #define FALSE 0 #define ERROR 0 struct 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"); scanf("%d",&carnum); 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() { FILE *fp; 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;} else fclose(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张卡\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; } else { 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"); getch(); }
  • 2021-09-08 18:13:51
  • 商品推荐