




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
封面數(shù)據(jù)結(jié)構(gòu)課程設(shè)計(jì)報(bào)告圖書管理信息系統(tǒng)二〇一三年十二月本程序是圖書管理信息系統(tǒng)的實(shí)現(xiàn),詳細(xì)功能包括讀者注冊(cè)、登錄、新書增添、圖書盤問(wèn)、圖書找尋、借還書、讀存盤等。程序流程以下:任務(wù)解析:1.新書入庫(kù):新到書籍入庫(kù)包括幾方面的操作:第一盤問(wèn)該書名的書籍在圖書館信息中可否已經(jīng)存在,若存在,則增添可借數(shù)量和總庫(kù)存量,若不存在,則新增添歸納信息,從界面輸入書籍的編號(hào)(0~999999的長(zhǎng)整型)、書名(字符串種類)、作者名(字符串種類)、初版社信息(字符串種類)、初版日期(整型)、該書的現(xiàn)存量(整型)、該書的總量(整型)。輸入該信息此后,將該節(jié)點(diǎn)插入到書籍信息鏈表中去。該節(jié)點(diǎn)的插入地址依照查找,找到合適的地址插入,這樣可以保證整個(gè)數(shù)據(jù)都是有序的,方便查找。2.讀者注冊(cè):沒(méi)有賬號(hào)和密碼讀者和管理員都不能夠登錄系統(tǒng),系統(tǒng)默認(rèn)第一個(gè)注冊(cè)系統(tǒng)的是系統(tǒng)管理員,借閱號(hào)為1000,權(quán)限是1,并輸入密碼000000及基本信息,并將所借書信息區(qū)全部置零。不是第一個(gè)注冊(cè)的讀者,借閱號(hào)從1000此后順延,自己設(shè)置密碼,權(quán)限為0,其他信息與管理員相同,因此登陸此后,管理員能夠看到“入庫(kù)”菜單項(xiàng)選擇項(xiàng),一般讀者不能夠看到該選項(xiàng)。3.借書:書籍借閱主要涉及存書庫(kù)和讀者信息庫(kù)的更新。用戶第一登陸系統(tǒng),經(jīng)過(guò)3種盤問(wèn)方式查詢?cè)摃煞翊嬖?,并判斷該書的?jié)余數(shù)量可否大于零,最后盤問(wèn)該讀者可否已經(jīng)借滿書籍。若以上條件都滿足,則將該書編號(hào)存入該讀者的借閱信息區(qū),將該讀者的可借書數(shù)量減1,該存書的可借數(shù)量減1。4.還書:讀者登錄后按書名號(hào)來(lái)歸還所借書籍,若書名號(hào)正確并且確認(rèn)歸還該書籍,則從讀者的借書區(qū)刪除該書籍,讀者的可借書數(shù)量加1,將該書的可借數(shù)量增添1,爾后返回。5.信息盤問(wèn):信息盤問(wèn)分為讀者信息盤問(wèn)和書籍信息盤問(wèn),讀者信息盤問(wèn)是在讀者登錄此后,能夠顯示本人的基本信息以及借書狀況(所借書的本數(shù)、可借書籍?dāng)?shù)以及所借書的信息),還可盤問(wèn)書籍信息,可依照書籍的編號(hào)來(lái)查找書籍、依照書名來(lái)查找書籍、依照作者名來(lái)盤問(wèn)書籍。盤問(wèn)到該書籍后顯示可否借閱該書籍。算法設(shè)計(jì):1、查找查找分按書名查找、按作者查找和按書號(hào)查找。按書名查找是采用遍歷線性鏈表的方式,從首元結(jié)點(diǎn)開(kāi)始向下遍歷,檢查輸入的書名和已存的書名可否般配,若是般配,則將該書籍的指針?lè)祷兀瑺柡蟛檎医Y(jié)束。若直到最后也沒(méi)找到,則返回空。按作者查找則依照輸入的作者名,從書籍鏈表的首元結(jié)點(diǎn)開(kāi)始遍歷,檢查記錄中的讀者信息和輸入的可否般配,若找到般配的,則輸出該書籍信息,爾后連續(xù)向下遍歷,直到鏈表尾部,查找結(jié)束。按書號(hào)查找則是依照建立的索引表來(lái)查找記錄。2、讀者信息儲(chǔ)藏讀者信息采用線性單鏈表儲(chǔ)藏,設(shè)置頭結(jié)點(diǎn),頭結(jié)點(diǎn)不儲(chǔ)藏?cái)?shù)據(jù),初始化時(shí)頭結(jié)點(diǎn)->next設(shè)置為空,爾后每從文件中讀取一組數(shù)據(jù),則將該數(shù)據(jù)存入新開(kāi)辟的空間,鏈接到讀者信息鏈表中,再將該數(shù)據(jù)的next置空。3、圖書信息儲(chǔ)藏書籍信息儲(chǔ)藏采用單鏈表儲(chǔ)藏,設(shè)置頭結(jié)點(diǎn),頭結(jié)點(diǎn)不儲(chǔ)藏?cái)?shù)據(jù),頭結(jié)點(diǎn)的next為空,初始化時(shí),從文件中讀取一個(gè)格式化的數(shù)據(jù),則將該數(shù)據(jù)存入新開(kāi)辟的空間,并將該節(jié)點(diǎn)鏈接到鏈表中去,將next置空。程序主要函數(shù):增添圖書:voidinsert(book*bhead);輸入書號(hào),判斷可否合法,爾后輸入圖書信息。流程圖以下2.借書:voidborrow(reader*temp,book*Bhead);經(jīng)過(guò)書號(hào)、書名、作者三種查找方式盤問(wèn)借書,借書成功后,該書的可借書量減1,讀者借書量減1。流程圖以下:還書:voidreturnbook(book*bhead,reader*temp);輸入書號(hào),盤問(wèn)可否存在,爾后還書,該書的可借書量加1,讀者借書量加1。流程圖以下:詳細(xì)程序模塊1、頭文件定義頭文件library.h定義了3個(gè)結(jié)構(gòu)體:書籍結(jié)構(gòu)體、讀者結(jié)構(gòu)體和索引表結(jié)構(gòu)體,書籍結(jié)構(gòu)體的定義以下:typedefstructREADER{longnumber;//借閱號(hào)charname[15];//讀者姓名charsex;//讀者性別charpassword[16];//讀者的密碼intresidue;//讀者的節(jié)余可借書籍?dāng)?shù)量longborrowed[10];//讀者已經(jīng)借閱的書籍編號(hào)intlimit;//讀者權(quán)限structREADER*next;}reader;讀者結(jié)構(gòu)體的定義以下:typedefstructBOOK{longnumber;//書籍編號(hào)charname[30];//書名charauthor[30];//作者charpress[30];//初版社信息longpresstime;//初版日期intexist;//在庫(kù)數(shù)量inttotal;//總數(shù)量structBOOK*next;}book;索引表結(jié)構(gòu)體的定義以下:typedefstructKEY{longkey;book*adress;structKEY*next;}keynode;頭文件還包括一些系統(tǒng)頭文件的聲明:#include"stdio.h"#include"string.h"#include"conio.h"#include"windows.h"還有一些函數(shù)的聲明,用#ifndef、#endif來(lái)包括,省得重復(fù)包括。2、插入模塊插入模塊分為書籍入庫(kù)、注冊(cè)、登陸3大塊,分3個(gè)函數(shù),聲明以下:voidinsert(book*bhead);//入庫(kù)voidreg(reader*head);//注冊(cè)reader*login(reader*rhead,book*bhead);//登陸這3個(gè)函數(shù)分別實(shí)現(xiàn)新書入庫(kù)、讀者注冊(cè)、登陸等功能,入庫(kù)功能只有管理員才能調(diào)用,其他函數(shù)均能夠調(diào)用。3、讀寫模塊此模塊主要實(shí)現(xiàn)向文件寫入、讀取數(shù),主若是2個(gè)文件:reader.txt、book.txt,分為數(shù):讀者讀寫函數(shù),書籍讀寫函數(shù)。定義以下:book*Bload();//書籍鏈表讀取reader*Rload();//讀者鏈表讀入voidBsave(book*Bhead);//書籍鏈表寫入
4個(gè)函voidRsave(reader*Rhead,book*bhead);//讀者鏈表寫入讀者和書籍鏈表的初始化就由讀取函數(shù)完成,若文件為空則返回空指針,若不為空,則將文件里面的信息寫入到鏈表中,每讀出一個(gè)數(shù)據(jù),分配一個(gè)空間,將該信息輸入。4、查找模塊查找模塊分書籍查找模塊、讀者查找模塊,書籍查找模塊分線性鏈表盤問(wèn)、遍歷盤問(wèn)、索引表盤問(wèn),讀者盤問(wèn)直接遍歷讀者鏈表,查找該讀者,若存在,返回指針,不存在則返回NULL。查找模塊的定義以下:book*S_name(book*head,charname[]);//按書籍名查找函數(shù)voidS_author(book*head);//按作者查找keynode*initindex(book*head);//初始化建立索引表book*S_number(longnum,book*bhead);//按書號(hào)查找reader*S_reader(reader*rhead,longnum);//查找讀者5、顯示模塊依照給出的節(jié)點(diǎn)指針,顯示該節(jié)點(diǎn)所包括的信息,顯示分為讀者顯示和書籍信息顯示,讀者信息顯示包括書籍信息顯示,以便顯示讀者所借書的信息。這兩個(gè)函數(shù)的聲明以下:voidshowR(reader*tr,book*bhead);//顯示讀者信息函數(shù)voidshowB(book*p);//顯示書籍信息函數(shù)這個(gè)模塊還有2個(gè)小函數(shù),用于將存入的性別’F’、M’’轉(zhuǎn)變?yōu)闈h字,將存的權(quán)限“1”、0“”轉(zhuǎn)變成“管理員”、“讀者”輸出,這兩個(gè)函數(shù)的定義以下:char*sc(charp){if(p=='F'||p=='f')return"女";elsereturn"男";}char*lc(inti){if(i==1)return"管理員";elsereturn"讀者";}程序運(yùn)行結(jié)果1.登錄界面:2.入庫(kù)界面:3.借書界面:4.還書界面:5.個(gè)人信息盤問(wèn)界面:領(lǐng)悟此次的大作業(yè)讓我復(fù)習(xí)并實(shí)質(zhì)運(yùn)用本學(xué)期學(xué)的數(shù)據(jù)結(jié)構(gòu)的有關(guān)知識(shí),比方數(shù)據(jù)的儲(chǔ)藏、排序、調(diào)用、查找等,加深了對(duì)數(shù)據(jù)結(jié)構(gòu)和C語(yǔ)言的理解,總的來(lái)說(shuō),得益匪淺。代碼頭文件library.h#ifndefLIBRARY_INCLUDE#defineLIBRARY_INCLUDE#include<stdio.h>#include<string.h>#include<conio.h>#include<stdlib.h>#include<windows.h>#include<time.h>typedefstructBOOK{longnumber;charname[30];charauthor[30];charpress[30];longpresstime;intexist;inttotal;structBOOK*next;}book;typedefstructKEY{longkey;book*adress;structKEY*next;}keynode;typedefstructREADER{longnumber;charname[15];charsex;charpassword[16];intresidue;longborrowed[10][2];intlimit;structREADER*next;}reader;char*lc(inti);char*sc(charp);voidshowR(reader*tr,book*bhead);voidshowB(book*p);book*S_name(book*head,charname[]);voidS_author(book*head);keynode*initindex(book*head);voiddelkey(keynode*keyhead);book*S_number(longnum,book*bhead);reader*S_reader(reader*rhead,longnum);book*Bload();reader*Rload();voidBsave(book*Bhead);voidRsave(reader*Rhead,book*bhead);voidinsert(book*bhead);voidreg(reader*head);reader*login(reader*rhead,book*bhead);voidborrow(reader*temp,book*Bhead);voidreturnbook(book*bhead,reader*temp);voidstyle();voidintpsd(char*psd);voidmenu(structBOOK*Bhead,reader*Rhead);voidmenu2(reader*temp,reader*rhead,book*bhead);longbacktime();#endif借還書文件borrow_return.cpp#include"library.h"voidborrow(reader*temp,book*Bhead){style();longnum;inti;chart,k,name[30];book*Bbook;getch();system("cls");while(1){printf("\n
┏━━━━━━━━━━┓");printf("\n
█━━━━━━━━━━━┫
借書
┣━━━━━━━━━━━█
");printf("\n
┗━━━━━━━━━━┛");printf("\n
請(qǐng)輸入您要查找借閱書籍的方式
:");printf("\n
1、按書號(hào)查找
\n");printf("\n
2、按作者查找
\n");printf("\n
3、按書名查找
\n");printf("\n
4、返回主菜單
\n");t=getch();switch(t){case'1':{printf("\n請(qǐng)輸入您要查找的書籍編號(hào)
:");scanf("%d",&num);if((Bbook=S_number(num,Bhead))!=NULL){showB(Bbook);printf("\n請(qǐng)問(wèn)你可否要借閱該書籍?Y/N");k=getch();if(k=='Y'||k=='y')gotoborrow;elsebreak;}elsebreak;}case'2':{S_author(Bhead);break;}case'3':{printf("\n請(qǐng)輸如您要查找的書籍名:");scanf("%s",name);if((Bbook=S_name(Bhead,name))!=NULL){showB(Bbook);printf("\n請(qǐng)問(wèn)你可否要借閱該書籍?Y/N");k=getch();if(k=='Y'||k=='y')gotoborrow;elsebreak;}elsecontinue;break;}default:return;borrow:if(Bbook!=NULL&&temp->residue>0&&Bbook->exist>0){temp->residue--;Bbook->exist--;for(i=0;i<10;i++){if(temp->borrowed[i][0]==0){temp->borrowed[i][0]=Bbook->number;temp->borrowed[i][1]=backtime();break;}}printf("\n
借閱成功
!");}elseif(!(temp->residue>0))printf("\n您只能借閱10本書籍!");elseif(!(Bbook->exist>0))printf("\n該書沒(méi)有庫(kù)存,請(qǐng)借閱其他書籍!");printf("\n您要連續(xù)借閱書籍嗎?Y/N");t=getch();if(t=='y'||t=='Y')continue;elsebreak;}}}voidreturnbook(book*bhead,reader*temp){longnum;inti,j=0;chart;book*p;printf("\n
┏━━━━━━━━━━┓");printf("\n
█━━━━━━━━━━━┫
還書
┣━━━━━━━━━━━█");printf("\n
┗━━━━━━━━━━┛");printf("\n\n請(qǐng)輸入您所還書的編號(hào)scanf("%d",&num);for(i=0;i<10;i++){
:");if(num==temp->borrowed[i][0])j=1;}p=S_number(num,bhead);if(p!=NULL&&j==1){printf("\n┌────┬──────┬───────┬────┬───────");printf("\n│書籍編號(hào)│書籍名稱│初版社名稱│初版時(shí)間│作者");printf("\n├────┼──────┼───────┼────┼───────");printf("\n│%8d│%12s│%14s│%8d│%14s│",p->number,p->name,p->press,p->presstime,p->author);printf("\n└────┴──────┴───────┴────┴───────\n");printf("\n確認(rèn)歸還該書籍?Y/N");t=getch();if(t=='Y'||t=='y'){p->exist++;temp->residue++;for(i=0;i<10;i++){if(temp->borrowed[i][0]==num){temp->borrowed[i][0]=0;temp->borrowed[i][1]=0;break;}}}elsereturn;}else{printf("\n編號(hào)有誤,請(qǐng)仔細(xì)檢查!");}}新書入庫(kù)insert.cpp#include"library.h"voidinsert(book*bhead){style();longt;book*temp1,*temp,*temp2;temp1=bhead->next;printf("\n
┏━━━━━━━━━━┓");printf("\n
█━━━━━━━━━━━┫
入庫(kù)
┣━━━━━━━━━━━");printf("\n┗━━━━━━━━━━┛");while(1){printf("\n請(qǐng)輸入您給定書的編號(hào)(6位之內(nèi)的正整數(shù)):");scanf("%d",&t);if(t<=0||t>999999){printf("\n您的編號(hào)不在辦理范圍(1~999999)之內(nèi)!");fflush(stdin);continue;}else{temp2=S_number(t,bhead);if(temp2==NULL){break;}else{temp2->total++;temp2->exist++;printf("\n編號(hào)為%d的書已存在,入庫(kù)成功!",t);return;}}}temp=(book*)malloc(sizeof(book));temp->number=t;printf("\n請(qǐng)輸入書名:");scanf("%s",temp->name);printf("\n請(qǐng)輸入本書作者:");scanf("%s",temp->author);printf("\n請(qǐng)輸入本書初版社:");scanf("%s",temp->press);printf("\n請(qǐng)輸入本書初版時(shí)間:");scanf("%d",&temp->presstime);temp->next=NULL;temp->total=1;temp->exist=1;if(bhead->next==NULL)bhead->next=temp;else{while(temp1->next!=NULL&&temp1->number<temp->number)temp1=temp1->next;temp->next=temp1->next;temp1->next=temp;}printf("\n
┏━━━━━━━━━━┓");printf("\n
█━━━━━━━━━━━┫
入庫(kù)成功
┣━━━━━━━━━━━█");printf("\n
┗━━━━━━━━━━┛");}voidreg(reader*head){style();longi=1000;intj;chart1[16],t2[16];reader*temp=head->next;reader*p;p=new(reader);printf("\n
┏━━━━━━━━━━┓");printf("\n
█━━━━━━━━━━━┫
注冊(cè)
┣━━━━━━━━━━━█");printf("\n
┗━━━━━━━━━━┛");printf("\n
請(qǐng)輸入姓名
:");scanf("%s",p->name);fflush(stdin);while(1){printf("\n
請(qǐng)輸入性別
:\n
M:男性:\n
F:女性:");p->sex=getchar();if(p->sex=='F'||p->sex=='f'||p->sex=='M'||p->sex=='m')break;elseprintf("\n
閣下既非男
,又非女
,莫非來(lái)自泰國(guó)
?");}while(1){while(1){printf("\n
請(qǐng)輸入您的密碼
:");intpsd(t1);if(strlen(t1)<=4)printf("\n
您設(shè)置的密碼過(guò)于簡(jiǎn)單
,請(qǐng)重新設(shè)置
:");elsebreak;}printf("\n
請(qǐng)確認(rèn)您的密碼
:");intpsd(t2);if(strcmp(t1,t2)==0){strcpy(p->password,t1);break;}elseprintf("\n
您兩次輸入的密碼不一致
!");}p->residue=10;p->next=NULL;for(j=0;j<10;j++){p->borrowed[j][0]=0;p->borrowed[j][1]=0;}if(temp==NULL){p->number=i;head->next=p;p->limit=1;}else{++i;while(temp->next!=NULL){++i;temp=temp->next;}p->number=i;p->limit=0;temp->next=p;}showR(p,NULL);}reader*login(reader*rhead,book*bhead){longnum;charpass[16];inti=5;reader*reader;style();printf("\n
┏━━━━━━━━━━┓");printf("\n
█━━━━━━━━━━━┫
登錄
┣━━━━━━━━━━━");printf("\n┗━━━━━━━━━━┛");while(1){printf("\n請(qǐng)輸入您的借閱證號(hào):");scanf("%d",&num);if((reader=S_reader(rhead,num))==NULL){printf("\n
沒(méi)有找到您所在編號(hào)的讀者
.");getch();returnNULL;}elsebreak;}while(i>0){printf("\n
請(qǐng)輸入密碼
:");intpsd(pass);if(strcmp(pass,reader->password)==0)returnreader;else{printf("\n
密碼錯(cuò)誤
");returnNULL;}}}文件讀、寫load_save.cpp#include"library.h"book*Bload(){FILE*p;book*Bhead=(book*)malloc(sizeof(book));book*temp,*temp1;Bhead->next=NULL;if((p=fopen("book.txt","r"))==NULL){printf("\n打開(kāi)文件book.txt失敗,請(qǐng)檢查...");returnBhead;}else{fgetc(p);if(!feof(p)){printf("\n非空");rewind(p);temp=(book*)malloc(sizeof(book));fscanf(p,"%14d%12s%18s%8d%14s%4d%4d\n",&temp->number,temp->name,temp->press,&temp->presstime,temp->author,&temp->total,&temp->exist);temp->next=NULL;Bhead->next=temp;}while(!feof(p)){temp1=(book*)malloc(sizeof(book));fscanf(p,"%14d%12s%18s%8d%14s%4d%4d\n",&temp1->number,temp1->name,temp1->press,&temp1->presstime,temp1->author,&temp1->total,&temp1->exist);temp1->next=NULL;temp->next=temp1;temp=temp->next;}printf("\n書籍信息讀取成功...");returnBhead;}}reader*Rload(){FILE*p;inti;reader*temp,*temp1;reader*Rhead=(reader*)malloc(sizeof(reader));Rhead->next=NULL;if((p=fopen("reader.txt","r"))==NULL){printf("\n打開(kāi)文件reader.txt失敗,請(qǐng)檢查");returnRhead;}else{fgetc(p);if(!feof(p)){rewind(p);temp=(reader*)malloc(sizeof(reader));fscanf(p,"%12d%10s%3c%8d%2d%12s",&temp->number,temp->name,&temp->sex,&temp->residue,&temp->limit,temp->password);for(i=0;i<10;i++){fscanf(p,"%6d",&temp->borrowed[i][0]);fscanf(p,"%10d",&temp->borrowed[i][1]);}temp->next=NULL;Rhead->next=temp;}while(!feof(p)){printf("\a");temp1=(reader*)malloc(sizeof(reader));fread(temp1,sizeof(reader),1,p);temp1->next=NULL;temp->next=temp1;temp=temp->next;}printf("\n讀者信息讀取成功...");returnRhead;}}voidBsave(book*Bhead){FILE*p;book*temp=Bhead->next;if(temp==NULL)return;else{if((p=fopen("book.txt","w"))==NULL)printf("\n打開(kāi)book.txt失敗...");while(temp!=NULL){showB(temp);fprintf(p,"%14d%12s%14s%8d%14s%4d%4d\n",temp->number,temp->name,temp->press,temp->presstime,temp->author,temp->total,temp->exist);temp=temp->next;}printf("\n儲(chǔ)藏書籍成功...");}}voidRsave(reader*Rhead,book*Bhead){FILE*p;inti;reader*temp=Rhead->next;if(temp==NULL)return;else{if((p=fopen("reader.txt","w"))==NULL)printf("\n打開(kāi)reader.txt失敗...");while(temp!=NULL){Sleep(1000);showR(temp,Bhead);fprintf(p,"%12d%10s%3c%8d%2d%12s",temp->number,temp->name,temp->sex,temp->residue,temp->limit,temp->password);for(i=0;i<10;i++){fprintf(p,"%6d",temp->borrowed[i][0]);fprintf(p,"%10d",temp->borrowed[i][1]);}temp=temp->next;}printf("\n儲(chǔ)藏讀者成功...");}}圖書找尋search.cpp#include"library.h"book*S_name(book*head,charname[]){book*temp=head->next;if(temp==NULL)printf("\n書庫(kù)中還沒(méi)有書籍,請(qǐng)入庫(kù)!");else{while(temp!=NULL){if(strcmp(temp->name,name)==0){printf("\n書名為<<%s>>的書存在!",name);break;}elsetemp=temp->next;}}returntemp;}voidS_author(book*head){charauthor[30];book*temp=head->next;if(temp==NULL)printf("\n書庫(kù)中還沒(méi)有書籍,請(qǐng)入庫(kù)!");else{printf("\n請(qǐng)輸入您要查找的作者名:");scanf("%s",author);while(temp!=NULL){if(strcmp(author,temp->author)==0)showB(temp);temp=temp->next;}}getch();}keynode*initindex(book*head){inti;book*temp=head->next;keynode*tempkey,*p;printf("\n初始化索引表開(kāi)始...");keynode*keyhead=(keynode*)malloc(sizeof(keynode));keyhead->next=NULL;tempkey=keyhead->next;if(temp!=NULL){p=(keynode*)malloc(sizeof(keynode));p->key=temp->number;p->adress=temp;p->next=NULL;keyhead->next=p;tempkey=keyhead->next;}while(temp!=NULL){for(i=0;i<5&&temp->next!=NULL;i++){temp=temp->next;}if(i<4)returnkeyhead;else{p=(keynode*)malloc(sizeof(keynode));p->key=temp->number;p->adress=temp;p->next=NULL;tempkey->next=p;tempkey=tempkey->next;}}getch();returnkeyhead;}voiddelkey(keynode*keyhead){keynode*temp;if(keyhead->next==NULL){free(keyhead);}else{while(keyhead!=NULL){temp=keyhead;keyhead=keyhead->next;free(temp);}}printf("\n索引表清空!");}book*S_number(longnum,book*bhead){inti;book*p;keynode*keyhead=initindex(bhead);keynode*tempkey=keyhead->next;if(tempkey==NULL){printf("\n書庫(kù)無(wú)記錄,請(qǐng)輸入!");delkey(keyhead);returnNULL;}else{while(tempkey->next!=NULL){if(tempkey->key<num&&tempkey->next->key<num)tempkey=tempkey->next;elsebreak;}if(tempkey==NULL){printf("沒(méi)有找到編號(hào)為%d的書籍!",num);delkey(keyhead);returnNULL;}else{p=tempkey->adress;for(i=0;i<5&&p!=NULL;i++){if(p->number==num){showB(p);delkey(keyhead);returnp;}elsep=p->next;}delkey(keyhead);returnNULL;}}}reader*S_reader(reader*rhead,longnum){reader*temp=rhead->next;if(temp==NULL){printf("\n文件中沒(méi)有數(shù)據(jù)導(dǎo)入,請(qǐng)檢查修復(fù)系統(tǒng)!");returnNULL;}else{while(temp){if(temp->number==num)returntemp;elsetemp=temp->next;}returntemp;}}顯示圖書及讀者信息showing.cpp#include"library.h"voidshowR(reader*tr,book*bhead){inti;book*p;printf("\n╔════════╗");printf("\n╔══════════╣讀者信息╠══════════╗");printf("\n║╚════════╝║");printf("\n╠══════╦═════╦═══╦════╦════╦═══╣");printf("\n║借閱證號(hào)║姓名║性別║節(jié)余可借║已借本數(shù)║權(quán)限║");printf("\n╠══════╬═════╬═══╬════╬════╬═══╣");printf("\n║%12d║%10s║%6s║%8d║%8d║%6s║",tr->number,tr->name,sc(tr->sex),tr->residue,10-tr->residue,lc(tr->limit));printf("\n╚══════╩═════╩═══╩════╩════╩═══╝");printf("\n以下為所借書籍信息:\n");for(i=0;i<10;i++){if(tr->borrowed[i][0]==0)continue;else{printf("\n%d",tr->borrowed[i][0]);p=S_number(tr->borrowed[i][0],bhead);printf("\n┌────┬──────┬───────┬────┬───────┬────┬────┐");printf("\n│書籍編號(hào)│書籍名稱│初版社名稱│初版時(shí)間│作者│借書日期│可借時(shí)間│");printf("\n├────┼──────┼───────┼────┼───────┼────┼────┤");printf("\n│%8d│%12s│%14s│%8d│%14s│%8d│2個(gè)月│",p->number,p->name,p->press,p->presstime,p->author,tr->borrowed[i][1]);printf("\n└────┴──────┴───────┴────┴───────┴────┴────┘\n");}}}voidshowB(book*p){printf("\n┌────┬──────┬───────┬────┬───────┬──┬──┐");printf("\n│書籍編號(hào)│書籍名稱│初版社名稱│初版時(shí)間│作者│共計(jì)│可借│");printf("\n├────┼──────┼───────┼────┼───────┼──┼──┤");printf("\n│%8d│%12s│%14s│%8d│%14s│%4d│%4d│",p->number,p->name,p->press,p->presstime,p->author,p->total,p->exist);printf("\n└────┴──────┴───────┴────┴───────┴──┴──┘\n");}char*sc(charp){if(p=='F'||p=='f')return"女";elsereturn"男";}char*lc(inti){if(i==1)return"管理員";elsereturn"讀者";}菜單menu.cpp#include"library.h"voidstyle(){system("modeconcols=90lines=30");system("color0f");system("cls");}voidintpsd(char*psd){inti=0;charc;while((c=getch())!=13){if(c!='\b'&&c!='\t'&&i<20){psd[i]=c;putchar('*');i++;}if(c=='\b'&&i>0){printf("\b\b");i--;}}psd[i]='\0';return;}voidmenu(book*Bhead,reader*Rhead){reader*tempr;style();charm;inti;while(1){printf("\n\t
┏━━━━━━━━━━┓");printf("\n\t
◢━━━━━━━━━━━┫
長(zhǎng)安大學(xué)圖書館
┣━━━━━━━━━━◣");printf("\n\t
┃
┗━━━━━━━━━━┛
┃");printf("\n\t
┃
┏━━━━━━━━┓
┃");printf("\n\t
┃
┃
┃
┃");printf("\n
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 紐馬克文本類型理論視角下的科普類文本翻譯實(shí)踐報(bào)告-以科普雜志《Техника-молодёжи》2022(01)的漢譯為例
- 公共交通系統(tǒng)緊急事件處理方案及風(fēng)險(xiǎn)措施
- 二年級(jí)語(yǔ)文上冊(cè)拼音復(fù)習(xí)教學(xué)計(jì)劃
- 交通事故私了協(xié)議書范文在保險(xiǎn)理賠中的應(yīng)用
- 體育行業(yè)選人用人自查報(bào)告范文
- 小學(xué)教師校際交流發(fā)展計(jì)劃
- 2025初中生物思維導(dǎo)圖復(fù)習(xí)計(jì)劃
- 2025年三年級(jí)班主任綜合素質(zhì)提升計(jì)劃
- 合同糾紛民事上訴書范文他
- “國(guó)際音樂(lè)跨界融合”音樂(lè)與其他藝術(shù)融合商業(yè)計(jì)劃書
- 整流器并聯(lián)運(yùn)行控制策略
- 農(nóng)業(yè)土壤檢測(cè)技術(shù)行業(yè)發(fā)展前景及投資風(fēng)險(xiǎn)預(yù)測(cè)分析報(bào)告
- 廣東省深圳市羅湖區(qū)2023-2024學(xué)年二年級(jí)下學(xué)期期末考試數(shù)學(xué)試題
- 初級(jí)美發(fā)師題庫(kù)
- DZ∕T 0214-2020 礦產(chǎn)地質(zhì)勘查規(guī)范 銅、鉛、鋅、銀、鎳、鉬(正式版)
- 博奧工程量清單計(jì)價(jià)軟件操作指南
- 2024年度-《醫(yī)療事故處理?xiàng)l例》解讀
- (2024年)面神經(jīng)炎課件完整版
- 宇宙星空基礎(chǔ)知識(shí)講座
- 2024年第九屆“學(xué)憲法、講憲法”知識(shí)題庫(kù)及答案
- 2024年重慶市林業(yè)局選任市林投公司招聘筆試參考題庫(kù)含答案解析
評(píng)論
0/150
提交評(píng)論