九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

圖書館管理系統(tǒng) 數(shù)據結構大作業(yè)

上傳人:p*** 文檔編號:43808986 上傳時間:2021-12-04 格式:DOC 頁數(shù):30 大?。?41.50KB
收藏 版權申訴 舉報 下載
圖書館管理系統(tǒng) 數(shù)據結構大作業(yè)_第1頁
第1頁 / 共30頁
圖書館管理系統(tǒng) 數(shù)據結構大作業(yè)_第2頁
第2頁 / 共30頁
圖書館管理系統(tǒng) 數(shù)據結構大作業(yè)_第3頁
第3頁 / 共30頁

下載文檔到電腦,查找使用更方便

20 積分

下載資源

還剩頁未讀,繼續(xù)閱讀

資源描述:

《圖書館管理系統(tǒng) 數(shù)據結構大作業(yè)》由會員分享,可在線閱讀,更多相關《圖書館管理系統(tǒng) 數(shù)據結構大作業(yè)(30頁珍藏版)》請在裝配圖網上搜索。

1、封面數(shù)據結構課程設計報告圖書管理信息系統(tǒng)二一三年十二月本程序是圖書管理信息系統(tǒng)的實現(xiàn),具體功能包括讀者注冊、登錄、新書增添、圖書查詢、圖書搜索、借還書、讀存盤等。程序流程如下:圖書管理信息系統(tǒng)注冊登陸讀者注冊管理員注冊讀者登錄管理員登錄入庫退出系統(tǒng)個人信息查詢還書借書任務分析:1新書入庫:新到書籍入庫包含幾方面的操作:首先查詢該書名的書籍在圖書館信息中是否已經存在,若存在,則增加可借數(shù)量和總庫存量,若不存在,則新增加概述信息,從界面輸入書籍的編號(0999999的長整型)、書名(字符串類型)、作者名(字符串類型)、出版社信息(字符串類型)、出版日期(整型)、該書的現(xiàn)存量(整型)、該書的總量(整

2、型)。輸入該信息之后,將該節(jié)點插入到書籍信息鏈表中去。該節(jié)點的插入位置根據查找,找到合適的位置插入,這樣可以保證整個數(shù)據都是有序的,方便查找。2讀者注冊:沒有賬號和密碼讀者和管理員都不能登錄系統(tǒng),系統(tǒng)默認第一個注冊系統(tǒng)的是系統(tǒng)管理員,借閱號為1000,權限是1,并輸入密碼000000及基本信息,并將所借書信息區(qū)全部置零.不是第一個注冊的讀者,借閱號從1000往后順延,自己設置密碼,權限為0,其余信息與管理員相同,因此登陸之后,管理員可以看到“入庫”菜單選項,普通讀者不能看到該選項。3借書:書籍借閱主要涉及存書庫和讀者信息庫的更新。用戶首先登陸系統(tǒng),通過3種查詢方式查詢該書是否存在,并判斷該書的

3、剩余數(shù)量是否大于零,最后查詢該讀者是否已經借滿書籍。若以上條件都滿足,則將該書編號存入該讀者的借閱信息區(qū),將該讀者的可借書數(shù)量減1,該存書的可借數(shù)量減1。4還書:讀者登錄后按書名號來歸還所借書籍,若書名號正確并且確認歸還該書籍,則從讀者的借書區(qū)刪除該書籍,讀者的可借書數(shù)量加1,將該書的可借數(shù)量增加1,然后返回.5信息查詢:信息查詢分為讀者信息查詢和書籍信息查詢,讀者信息查詢是在讀者登錄之后,可以顯示本人的基本信息以及借書狀況(所借書的本數(shù)、可借書本數(shù)以及所借書的信息),還可查詢書籍信息,可根據書籍的編號來查找書籍、根據書名來查找書籍、根據作者名來查詢書籍。查詢到該書籍后顯示是否借閱該書籍。算法

4、設計:1、 查找查找分按書名查找、按作者查找和按書號查找。按書名查找是采用遍歷線性鏈表的方式,從首元結點開始向下遍歷,檢查輸入的書名和已存的書名是否匹配,如果匹配,則將該書籍的指針返回,然后查找結束.若直到最后也沒找到,則返回空。按作者查找則根據輸入的作者名,從書籍鏈表的首元結點開始遍歷,檢查記錄中的讀者信息和輸入的是否匹配,若找到匹配的,則輸出該書籍信息,然后繼續(xù)向下遍歷,直到鏈表尾部,查找結束。按書號查找則是根據建立的索引表來查找記錄。2、 讀者信息存儲讀者信息采用線性單鏈表存儲,設置頭結點,頭結點不存儲數(shù)據,初始化時頭結點next設置為空,然后每從文件中讀取一組數(shù)據,則將該數(shù)據存入新開辟

5、的空間,鏈接到讀者信息鏈表中,再將該數(shù)據的next置空。3、圖書信息存儲書籍信息存儲采用單鏈表存儲,設置頭結點,頭結點不存儲數(shù)據,頭結點的next為空,初始化時,從文件中讀取一個格式化的數(shù)據,則將該數(shù)據存入新開辟的空間,并將該節(jié)點鏈接到鏈表中去,將next置空。程序主要函數(shù):1. 增加圖書:void insert(bookbhead);輸入書號,判斷是否合法,然后輸入圖書信息。流程圖如下進入輸入書號N書號合法輸入書籍信息YY結束輸入N繼續(xù)輸入2. 借書:void borrow(reader *temp,book*Bhead);通過書號、書名、作者三種查找方式查詢借書,借書成功后,該書的可借書量

6、減1,讀者借書量減1。流程圖如下:N進入查找按書名查找按書號查找按作者查找進入輸入書名繼續(xù)借書退出輸入書號輸入作者未找到找到借書找到借書成功YNYYN3. 還書:void returnbook(book*bhead,reader *temp);輸入書號,查詢是否存在,然后還書,該書的可借書量加1,讀者借書量加1。流程圖如下:進入還書輸入書號存在還書還書成功退出YNYN詳細程序模塊1、頭文件定義頭文件library.h定義了3個結構體:書籍結構體、讀者結構體和索引表結構體,書籍結構體的定義如下:typedefstruct READERlong number;/借閱號char name15;/讀者

7、姓名char sex;/讀者性別char password16;/讀者的密碼int residue;/讀者的剩余可借書籍數(shù)量long borrowed10;/讀者已經借閱的書籍編號int limit;/讀者權限struct READER *next; reader;讀者結構體的定義如下:typedefstruct BOOKlong number;/書籍編號char name30;/書名char author30;/作者char press30;/出版社信息long presstime;/出版日期int exist;/在庫數(shù)量int total;/總數(shù)量struct BOOK next; boo

8、k;索引表結構體的定義如下:typedefstruct KEY long key;book adress;struct KEY next;keynode;頭文件還包含一些系統(tǒng)頭文件的聲明:#include”stdio。h”includestring.h#include”conio.h”include”windows.h”還有一些函數(shù)的聲明,用#ifndef、#endif來包含,以免重復包含。2、插入模塊插入模塊分為書籍入庫、注冊、登陸3大塊,分3個函數(shù),聲明如下:void insert(book*bhead);/入庫void reg(readerhead);/注冊reader login(re

9、ader*rhead,book*bhead);/登陸這3個函數(shù)分別實現(xiàn)新書入庫、讀者注冊、登陸等功能,入庫功能只有管理員才能調用,其余函數(shù)均可以調用。3、讀寫模塊此模塊主要實現(xiàn)向文件寫入、讀取數(shù),主要是2個文件:reader.txt、book。txt,分為4個函數(shù):讀者讀寫函數(shù),書籍讀寫函數(shù)。定義如下:book* Bload();/書籍鏈表讀取readerRload();/讀者鏈表讀入void Bsave(bookBhead);/書籍鏈表寫入void Rsave(readerRhead,book*bhead);/讀者鏈表寫入讀者和書籍鏈表的初始化就由讀取函數(shù)完成,若文件為空則返回空指針,若不為

10、空,則將文件里面的信息寫入到鏈表中,每讀出一個數(shù)據,分配一個空間,將該信息輸入.4、查找模塊查找模塊分書籍查找模塊、讀者查找模塊,書籍查找模塊分線性鏈表查詢、遍歷查詢、索引表查詢,讀者查詢直接遍歷讀者鏈表,查找該讀者,若存在,返回指針,不存在則返回NULL。查找模塊的定義如下:bookS_name(bookhead,char name);/按書籍名查找函數(shù)void S_author(bookhead);/按作者查找keynodeinitindex(bookhead);/初始化建立索引表book*S_number(long num,book*bhead);/按書號查找readerS_reader

11、(reader*rhead,longnum);/查找讀者5、顯示模塊根據給出的節(jié)點指針,顯示該節(jié)點所包含的信息,顯示分為讀者顯示和書籍信息顯示,讀者信息顯示包含書籍信息顯示,以便顯示讀者所借書的信息。這兩個函數(shù)的聲明如下:void showR(readertr,bookbhead);/顯示讀者信息函數(shù)void showB(bookp);/顯示書籍信息函數(shù)這個模塊還有2個小函數(shù),用于將存入的性別F、M轉化成漢字,將存的權限“1”、“0”轉化成“管理員”、“讀者”輸出,這兩個函數(shù)的定義如下:char*sc(char p)if(p=F|p=f)return ”女”;elsereturn ”男”;ch

12、ar*lc(int i)if(i=1)return ”管理員;elsereturn 讀者”;程序運行結果1.登錄界面:2。入庫界面:3.借書界面:4.還書界面:5.個人信息查詢界面:體會這次的大作業(yè)讓我復習并實際運用本學期學的數(shù)據結構的有關知識,例如數(shù)據的存儲、排序、調用、查找等,加深了對數(shù)據結構和C語言的理解,總的來說,收獲頗豐。代碼頭文件library。h#ifndef LIBRARY_INCLUDE#define LIBRARY_INCLUDEincludestdio。hincludestring。hincludeconio.hincludeincludeexist0)temp-resi

13、due-;Bbookexist;for(i=0;i10;i+)if(temp-borrowedi0=0)temp-borrowedi0=Bbook-number;temp-borrowedi1=backtime();break;printf(”n 借閱成功!”);elseif(!(tempresidue0))printf(n您只能借閱10本書籍!);elseif(!(Bbookexist0))printf(”n該書沒有庫存,請借閱其他書籍!”);printf(”n您要繼續(xù)借閱書籍嗎?Y/N”);t=getch();if(t=y|t=Y)continue;elsebreak;voidreturn

14、book(book *bhead,reader *temp)longnum;inti,j=0;char t;book p;printf(n );printf(”n還書);printf(n ”);printf(”nn請輸入您所還書的編號:”);scanf(d,num);for(i=0;iborrowedi0)j=1;p=S_number(num,bhead);if(p!=NULLj=1)printf(n”);printf(n書本編號書籍名稱出版社名稱出版時間作者”);printf(n);printf(n8d%12s14s8d%14s,pnumber,pname,p-press,ppresstim

15、e,pauthor);printf(nn);printf(n確認歸還該書籍?Y/N);t=getch();if(t=Y|t=y)p-exist+;temp-residue+;for(i=0;i10;i+)if(temp-borrowedi0=num)temp-borrowedi0=0;temp-borrowedi1=0;break;else return;elseprintf(”n編號有誤,請仔細檢查!);新書入庫insert.cpp#include ”library.h”void insert(book *bhead)style();long t;book *temp1,*temp,*tem

16、p2;temp1=bhead-next;printf(”n );printf(n入庫);printf(”n ”);while(1)printf(n請輸入您給定書的編號(6位以內的正整數(shù)):);scanf(”d,&t);if(t=0|t999999)printf(”n您的編號不在處理范圍(1999999)之內!”);fflush(stdin);continue;elsetemp2=S_number(t,bhead);if(temp2=NULL)break;elsetemp2total+;temp2exist+;printf(”n編號為d的書已存在,入庫成功!”,t);return;temp=(b

17、ook)malloc(sizeof(book));temp-number=t;printf(”n請輸入書名:);scanf(s”,temp-name);printf(n請輸入本書作者:);scanf(s,tempauthor);printf(”n請輸入本書出版社:”);scanf(”%s”,temp-press);printf(n請輸入本書出版時間:”);scanf(”d”,temp-presstime);tempnext=NULL;temp-total=1;tempexist=1;if(bhead-next=NULL)bhead-next=temp;elsewhile(temp1next!=

18、NULL&temp1-numbertemp-number)temp1=temp1-next;tempnext=temp1-next;temp1-next=temp;printf(”n );printf(”n入庫成功);printf(n );voidreg(reader *head)style();long i=1000;int j;char t116,t216;reader *temp=headnext;reader *p;p=new(reader);printf(n ”);printf(”n注冊”);printf(”n );printf(n 請輸入姓名:”);scanf(”s,pname);

19、fflush(stdin);while(1)printf(n 請輸入性別:n M:男性:n F:女性:”);p-sex=getchar();if(psex=F|psex=f|psex=Mp-sex=m)break;elseprintf(n 閣下既非男,又非女,莫非來自泰國?”);while(1)while(1)printf(n 請輸入您的密碼:”);intpsd(t1);if(strlen(t1)=4)printf(”n 您設置的密碼過于簡單,請重新設置:);elsebreak;printf(n 請確認您的密碼:”);intpsd(t2);if(strcmp(t1,t2)=0)strcpy(p

20、-password,t1);break;elseprintf(”n 您兩次輸入的密碼不一致!);presidue=10;p-next=NULL;for(j=0;jborrowedj0=0;pborrowedj1=0;if(temp=NULL)pnumber=i;head-next=p;p-limit=1;else+i;while(temp-next!=NULL)+i;temp=temp-next;p-number=i;plimit=0;tempnext=p;showR(p,NULL);reader *login(reader rhead,book *bhead)longnum;char pas

21、s16;int i=5;reader reader;style();printf(”n ”);printf(n登錄);printf(”n ”);while(1)printf(”n 請輸入您的借閱證號:);scanf(d”,num);if(reader=S_reader(rhead,num))=NULL)printf(”n 沒有找到您所在編號的讀者?!保?getch();return NULL;elsebreak;while(i0)printf(”n 請輸入密碼:”);intpsd(pass);if(strcmp(pass,readerpassword)=0)return reader;else

22、printf(”n 密碼錯誤);return NULL;文件讀、寫load_save。cppinclude library.hbook Bload()FILE *p;book *Bhead=(book*)malloc(sizeof(book);book temp,temp1;Bhead-next=NULL;if(p=fopen(book.txt,”r”))=NULL)printf(”n打開文件book.txt失敗,請檢查.。.);returnBhead;elsefgetc(p);if(!feof(p))printf(n非空);rewind(p);temp=(book)malloc(sizeof

23、(book);fscanf(p,”14d12s%18s8d14s4d4dn,temp-number,temp-name,temppress,&temppresstime,tempauthor,temp-total,temp-exist);tempnext=NULL;Bhead-next=temp;while(!feof(p)temp1=(book*)malloc(sizeof(book));fscanf(p,%14d%12s18s8d%14s%4d4dn,temp1number,temp1name,temp1-press,temp1presstime,temp1-author,temp1-to

24、tal,temp1exist);temp1next=NULL;tempnext=temp1;temp=tempnext;printf(”n書籍信息讀取成功。.);returnBhead;reader Rload()FILE *p;int i;reader *temp,*temp1;reader *Rhead=(reader)malloc(sizeof(reader);Rhead-next=NULL;if((p=fopen(”reader。txt”,r))=NULL)printf(”n打開文件reader.txt失敗,請檢查”);returnRhead;elsefgetc(p);if(!feof

25、(p))rewind(p);temp=(reader*)malloc(sizeof(reader));fscanf(p,%12d%10s%3c%8d2d12s”,tempnumber,tempname,&temp-sex,&tempresidue,temp-limit,temp-password);for(i=0;i10;i+)fscanf(p,%6d”,temp-borrowedi0);fscanf(p,%10d”,&tempborrowedi1);tempnext=NULL;Rhead-next=temp;while(!feof(p)printf(a);temp1=(reader*)mal

26、loc(sizeof(reader));fread(temp1,sizeof(reader),1,p);temp1-next=NULL;tempnext=temp1;temp=temp-next;printf(n讀者信息讀取成功。.”);returnRhead;voidBsave(book *Bhead)FILE p;book *temp=Bhead-next;if(temp=NULL)return;elseif(p=fopen(”book.txt,w”))=NULL)printf(n打開book。txt失敗.”);while(temp!=NULL)showB(temp);fprintf(p,

27、”%14d%12s14s%8d14s4d%4dn,tempnumber,temp-name,temp-press,temppresstime,tempauthor,temptotal,tempexist);temp=tempnext;printf(”n存儲書籍成功.);voidRsave(reader Rhead,book Bhead)FILE p;int i;reader temp=Rhead-next;if(temp=NULL)return;elseif((p=fopen(reader.txt,”w))=NULL)printf(”n打開reader。txt失敗.?!?;while(temp

28、!=NULL)Sleep(1000);showR(temp,Bhead);fprintf(p,”12d10s%3c8d%2d%12s”,tempnumber,temp-name,tempsex,tempresidue,templimit,temppassword);for(i=0;iborrowedi0);fprintf(p,%10d”,tempborrowedi1);temp=tempnext;printf(n存儲讀者成功。.。);圖書搜索search.cpp#include”library。h”book *S_name(book *head,char name)book temp=head

29、-next;if(temp=NULL)printf(n書庫中還沒有書籍,請入庫!”);elsewhile(temp!=NULL)if(strcmp(temp-name,name)=0)printf(”n書名為next;if(temp=NULL)printf(”n書庫中還沒有書籍,請入庫!”);elseprintf(n請輸入您要查找的作者名:”);scanf(”s”,author);while(temp!=NULL)if(strcmp(author,tempauthor)=0)showB(temp);temp=temp-next;getch();keynode *initindex(book h

30、ead)int i;book temp=head-next;keynode *tempkey,p;printf(n初始化索引表開始?!?;keynode *keyhead=(keynode*)malloc(sizeof(keynode);keyheadnext=NULL;tempkey=keyheadnext;if(temp!=NULL)p=(keynode*)malloc(sizeof(keynode);p-key=tempnumber;padress=temp;p-next=NULL;keyheadnext=p;tempkey=keyhead-next;while(temp!=NULL)f

31、or(i=0;i5&tempnext!=NULL;i+)temp=tempnext;if(inext=p;tempkey=tempkey-next;getch();returnkeyhead;voiddelkey(keynode *keyhead)keynode temp;if(keyhead-next=NULL)free(keyhead);elsewhile(keyhead!=NULL)temp=keyhead;keyhead=keyheadnext;free(temp);printf(n索引表清空!”);book S_number(long num,book bhead)int i;boo

32、k *p;keynode keyhead=initindex(bhead);keynode *tempkey=keyhead-next;if(tempkey=NULL)printf(”n書庫無記錄,請輸入!);delkey(keyhead);return NULL;elsewhile(tempkey-next!=NULL)if(tempkeykeykeynext;else break;if(tempkey=NULL)printf(沒有找到編號為d的書籍!,num);delkey(keyhead);return NULL;elsep=tempkeyadress;for(i=0;inext;del

33、key(keyhead);return NULL;reader S_reader(reader rhead,longnum)reader *temp=rheadnext;if(temp=NULL)printf(n文件中沒有數(shù)據導入,請檢查修復系統(tǒng)!”);return NULL;elsewhile(temp)if(tempnumber=num)return temp;elsetemp=tempnext;return temp;顯示圖書及讀者信息showing.cpp#includelibrary.hvoidshowR(reader *tr,book bhead)int i;book p;prin

34、tf(n );printf(”n讀者信息”);printf(n);printf(n);printf(n借閱證號姓名性別剩余可借已借本數(shù)權限);printf(n);printf(”n12d10s6s8d%8d%6s,tr-number,trname,sc(trsex),tr-residue,10-tr-residue,lc(tr-limit));printf(n);printf(n 以下為所借書籍信息:n);for(i=0;iborrowedi0);p=S_number(tr-borrowedi0,bhead);printf(n”);printf(n書本編號書籍名稱出版社名稱出版時間作者借書日期

35、可借時間);printf(”n);printf(”n8d12s%14s8d%14s%8d 2個月”,pnumber,pname,ppress,p-presstime,p-author,tr-borrowedi1);printf(nn”);voidshowB(book *p)printf(”n);printf(n書本編號書籍名稱出版社名稱出版時間作者共計可借);printf(n”);printf(”n%8d%12s%14s%8d14s4d4d”,p-number,pname,ppress,ppresstime,p-author,ptotal,p-exist);printf(nn);char *s

36、c(char p)if(p=F|p=f)return 女;elsereturn 男;char lc(int i)if(i=1)return 管理員;elsereturn ”讀者”;菜單menu。cpp#include library.h”void style()system(mode con cols=90 lines=30);system(”color 0f);system(cls);voidintpsd(char psd)int i=0; char c;while((c=getch())!=13)if (c!=b&c!=t&i20)psdi=c;putchar(*);i+;if(c=b&i

37、0)printf(b b);i; psdi=0;return;void menu(book *Bhead,reader *Rhead)reader tempr;style();charm;int i;while(1)printf(nt );printf(nt長安大學圖書館”);printf(”nt”);printf(nt”);printf(nt);printf(”nt);printf(nt 1登陸);printf(nt);printf(nt 2注冊”);printf(”nt);printf(”nt”);printf(”nt);printf(”nt按任意鍵退出”);printf(ntn”);fflush(stdin);m=getch();if(m=2)char message = n正在進入請稍候. ;for(i=0;istrlen(message);i+)printf(”c”,messagei);Sleep(50);system(”cls”);reg(Rhead);elseif(m=1)char message = n正在進入請稍候.。 ;for(i=0;ilimit=1) printf(”n 6入庫”);else ;printf(n”);printf(n

展開閱讀全文
溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
5. 裝配圖網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

相關資源

更多
正為您匹配相似的精品文檔
關于我們 - 網站聲明 - 網站地圖 - 資源地圖 - 友情鏈接 - 網站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網版權所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對上載內容本身不做任何修改或編輯。若文檔所含內容侵犯了您的版權或隱私,請立即通知裝配圖網,我們立即給予刪除!