




已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
此文檔收集于網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系網(wǎng)站刪除圖書管理系統(tǒng)精品文檔目錄1. 課程設(shè)計名稱.12.課程設(shè)計目的.13課程設(shè)計流程圖.14.實驗內(nèi)容.1(1) 新書注冊模塊.3(2)借書模塊.4(3)查閱圖書.5(4)舊圖書的注銷:.6(5)歸還圖書模塊:.7(6)統(tǒng)計圖書85.程序源代碼:.86.心得體會.137.參考文獻(xiàn).141.課程設(shè)計名稱:圖書管理系統(tǒng)2.課程設(shè)計目的(1)加深對文件系統(tǒng)概念的理解,明確文件系統(tǒng)等的運用。(2)熟悉在Liunx環(huán)境下的簡單程序編程。(3)以Linux系統(tǒng)文件部分系統(tǒng)調(diào)用為基礎(chǔ)設(shè)計一個簡易的圖書管理系統(tǒng)。包括圖書的錄入、查詢、借閱、清理、統(tǒng)計等功能。3課程設(shè)計流程圖進(jìn)入圖書管理系統(tǒng)2借圖書1注冊新書6統(tǒng)計圖書5歸還圖書4注銷舊書請執(zhí)行你要做的操作0退出3查閱圖書4.實驗內(nèi)容以Linux系統(tǒng)文件部分系統(tǒng)調(diào)用為基礎(chǔ)設(shè)計一個的圖書管理系統(tǒng)。要求實現(xiàn):圖書的錄入、查詢、借閱、清理、統(tǒng)計等功能、還要實現(xiàn)對每天的借閱情況進(jìn)行統(tǒng)計。(1) 注冊新書模塊:在此方法book_add()中要充分運用文件指針的運用。通過定義FILE * fp;對文件進(jìn)行一系列的調(diào)整,在新書的注冊的時候不會出現(xiàn)指針的覆蓋,首先以隨機讀寫的方式打開文件,用來避免在打開文件的指針都指向第一個位置的情況通過聲明圖書的有關(guān)屬性作為一個數(shù)據(jù)結(jié)構(gòu)struct BOOK。struct BOOK int id,usr10,total,store,days10; char name31,author21; books100;/*以上是數(shù)據(jù)結(jié)構(gòu)*/void book_add() char a; FILE * fp; int n=0; int c; if(fp=fopen(bbb,ab+)=NULL) /* 讀寫方式打開或建立新文件*/ printf(cannot open filen); return ; page_title(注冊新書);do printf(序號:); scanf(%d,&booksn.id); printf(書名:); scanf(%s,&); printf(作者:); scanf(%s,&booksn.author); printf(數(shù)量:); scanf(%d,&booksn.total); booksn.store=booksn.total; n+; printf(繼續(xù)注冊:1.是 2.否); scanf(%d,&c);while(c=1); if(fwrite(books,sizeof(struct BOOK),n, fp)!=n) printf( file write error); fclose(fp); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); (2)借書模塊借閱圖書模塊book_out()是是通過定義是數(shù)據(jù)結(jié)構(gòu)在通過查找模塊找到該書時是通過書的圖書號進(jìn)行借閱。void book_out() char a; int n,s,l,d; page_title(借閱圖書); if(n=search_book()!=-1&booksn.store0) printf(請輸入借書證序號:); scanf(%d,&s); printf(請輸入可借天數(shù):); scanf(%d,&d); for(l=0;l10;l+) if(booksn.usrl=0) booksn.usrl=s; booksn.daysl=d; break; booksn.store-; out+; if(n!=-1&booksn.store=0) printf(此書已經(jīng)全部借出.n); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); /*上面是借書的函數(shù),首先調(diào)用找書函數(shù)*/(3)借閱圖書在查閱圖書的模塊中search_book()定義了文件bbb用與存儲圖書數(shù)據(jù),然后通過該數(shù)據(jù)結(jié)構(gòu)進(jìn)行圖書查詢int search_book() char a; /* 用以查看結(jié)果*/ int n=0,i=0; FILE * fp; if(fp=fopen(bbb,r)=NULL) /* 讀方式打開*/ printf(cannot open filen); while(!feof(fp) /*把文件寫入內(nèi)存,books要初始化 */ fread(&booksi,sizeof(struct BOOK),1, fp); i+; fclose(fp); printf(請輸入圖書序號:); scanf(%d,&i); for(n=0;n100;n+) if(booksn.id=i) printf(書名:%sn,); printf(作者:%sn,booksn.author); printf(存數(shù):%d n,booksn.store); printf(總數(shù):%d n,booksn.total); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); return n; printf(n輸入錯誤或無效圖書序號.n); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); return -1; /*上面的函數(shù)是在數(shù)組中找到圖書號匹配的記錄,顯示其信息并返 回數(shù)組下標(biāo),如果找不到相應(yīng)記錄則提示錯誤并返回-1。*/(4)舊圖書的注銷:在book_del()通過書的書號在文件中進(jìn)行消除void book_del(void) char a; int n,i; page_title(注銷舊書); if(n=search_book()!=-1) booksn.id=0; for(i=0;i31;i+) i=NULL; for(i=0;i21;i+) booksn.authori=NULL; booksn.total=0; booksn.store=0; printf(該書已注銷.n); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); (5)歸還圖書模塊:圖書歸還模塊book_in是通過圖書的書號進(jìn)行的,在進(jìn)行歸還的同時要通過文件指針在進(jìn)行調(diào)整。void book_in(void) char a; int n,s,l; page_title(歸還圖書); if(n=search_book()!=-1&booksn.storebooksn.total) printf(借閱者圖書證列表:n); for(l=0;l10;l+) if (booksn.usrl!=0) printf(%d - %d天,booksn.usrl,booksn.daysl); printf(請輸入借書證序號:); scanf(%d,&s); for(l=0;l10;l+) if(booksn.usrl=s) booksn.usrl=0; booksn.daysl=0; break; booksn.store+; in-; if(n!=-1&booksn.store=booksn.total) printf(全部入藏.n); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); (6)統(tǒng)計圖書void tongji() char a; printf(借出總數(shù)%dn,out ); printf(歸還總數(shù)%dn,in); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y);4.程序源代碼:/* 圖書管理系統(tǒng)*/#include #include struct BOOK int id,usr10,total,store,days10; char name31,author21; books100;/*上面是結(jié)構(gòu)體的定義,用于存放書籍及借書的信息。*/int out=0,in=0; /*統(tǒng)計借出和歸還*/ void page_title(char *menu_item) printf( 圖 書 管 理 系 統(tǒng) nn- %s nn,menu_item); /*上面是打印頁眉的函數(shù),同時通過參數(shù)menu_item,可以顯示當(dāng)前的狀態(tài)。*/int search_book() char a; /* 用以查看結(jié)果*/ int n=0,i=0; FILE * fp; if(fp=fopen(bbb,r)=NULL) /* 讀方式打開*/ printf(cannot open filen); while(!feof(fp) /*把文件寫入內(nèi)存,books要初始化 */ fread(&booksi,sizeof(struct BOOK),1, fp); i+; fclose(fp); printf(請輸入圖書序號:); scanf(%d,&i); for(n=0;n0) printf(請輸入借書證序號:); scanf(%d,&s); printf(請輸入可借天數(shù):); scanf(%d,&d); for(l=0;l10;l+) if(booksn.usrl=0) booksn.usrl=s; booksn.daysl=d; break; booksn.store-; out+; if(n!=-1&booksn.store=0) printf(此書已經(jīng)全部借出.n); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); /*上面是借書的函數(shù),首先調(diào)用找書函數(shù)*/void book_in(void) char a; int n,s,l; page_title(歸還圖書); if(n=search_book()!=-1&booksn.storebooksn.total) printf(借閱者圖書證列表:n); for(l=0;l10;l+) if (booksn.usrl!=0) printf(%d - %d天n,booksn.usrl,booksn.daysl); printf(請輸入借書證序號:); scanf(%d,&s); for(l=0;l10;l+) if(booksn.usrl=s) booksn.usrl=0; booksn.daysl=0; break; booksn.store+; in-; if(n!=-1&booksn.store=booksn.total) printf(全部入藏.n); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); void book_add() char a; FILE * fp; int n=0; int c; if(fp=fopen(bbb,ab+)=NULL) /* 讀寫方式打開或建立新文件*/ printf(cannot open filen); return ; page_title(注冊新書);do printf(序號:); scanf(%d,&booksn.id); printf(書名:); scanf(%s,&); printf(作者:); scanf(%s,&booksn.author); printf(數(shù)量:); scanf(%d,&booksn.total); booksn.store=booksn.total; n+; printf(繼續(xù)注冊:1.是 2.否); scanf(%d,&c);while(c=1); if(fwrite(books,sizeof(struct BOOK),n, fp)!=n) printf( file write error); fclose(fp); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); void book_del(void) char a; int n,i; page_title(注銷舊書); if(n=search_book()!=-1) booksn.id=0; for(i=0;i31;i+) i=NULL; for(i=0;i21;i+) booksn.authori=NULL; booksn.total=0; booksn.store=0; printf(該書已注銷.n); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y); void tongji() char a; printf(借出總數(shù)%dn,out ); printf(歸還總數(shù)%dn,in); do printf(結(jié)束? y/n); scanf( %c,&a); while(a!=y);void main(void) char c;int i,j;for(i=0;i100;i+) for(j=0;j30;j+) j=NULL; for(j=0;j20;j+) booksi.authorj=NULL;menu: page_title(操作選單); printf(請用數(shù)字鍵選擇操作nn); printf(1 借閱圖書n2 歸還圖書nn); printf(3 注冊新書n4 注銷舊書nn); printf(5 統(tǒng)計n); printf(6 圖書查詢n);printf(n0 退出n); scanf(%c,&c); switch(c) case 1 : book_out();break; case 2 : book_in();break; case 3 : book_add();break; case 4 : book_del();break; case 5: tongji();break; case 6: search_b
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030中國尼龍防靜電電子手套行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 2025-2030中國小麥蛋白行業(yè)消費前景及發(fā)展趨勢預(yù)測分析研究報告
- 2025-2030中國小微金融行業(yè)創(chuàng)新策略及投資價值評估研究報告
- 機械模型企業(yè)制定與實施新質(zhì)生產(chǎn)力戰(zhàn)略研究報告
- 智慧城市行業(yè)直播電商戰(zhàn)略研究報告
- 2025-2030中國家用發(fā)光二極管條行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 2025-2030中國安防系統(tǒng)行業(yè)市場深度調(diào)研及競爭格局與投資研究報告
- 2025-2030中國安全帶行業(yè)供需趨勢及投資風(fēng)險研究報告
- 篆刻藝術(shù)創(chuàng)作行業(yè)跨境出海戰(zhàn)略研究報告
- 2025-2030中國嬰兒護(hù)膚品行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 現(xiàn)代漢語語法(2)短語課件
- 冰雪之都冰城哈爾濱旅游宣傳風(fēng)土人情城市介紹PPT圖文課件
- (完整版)鋼琴五線譜(A4打印)
- 量子力學(xué)完整版課件
- 生態(tài)修復(fù)地質(zhì)勘察報告
- 廣東廣州市海珠區(qū)官洲街道辦事處政府雇員公開招聘5人(必考題)模擬卷含答案
- 結(jié)構(gòu)膠msdslord第一部分化學(xué)產(chǎn)品和公司名稱
- 低血糖昏迷搶救預(yù)案及流程
- 新教材教科版四年級下冊科學(xué)全冊課時練(同步練習(xí))(共24課)
- 從專業(yè)走向管理
- 2022年中國礦業(yè)權(quán)評估新準(zhǔn)則
評論
0/150
提交評論