版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、課程設(shè)計(大作業(yè))報告課程名稱: 數(shù)據(jù)結(jié)構(gòu)課程設(shè)計設(shè)計題目: 小型圖書館管理系統(tǒng)院 系: 信息技術(shù)學(xué)院 班 級: 計算機科學(xué)與技術(shù) 3班 設(shè) 計 者:學(xué) 號: 2011110 指導(dǎo)教師: 王亞寧 設(shè)計時間: 2012.12.24-28 昆明學(xué)院課程設(shè)計(大作業(yè))任務(wù)書姓 名:院(系):信息技術(shù)學(xué)院專 業(yè):計算機科學(xué)與技術(shù)學(xué) 號:2011110任務(wù)起止日期:2012.12.24-28課程設(shè)計題目:小型圖書館管理系統(tǒng)課程設(shè)計要求:設(shè)計目的:對C語言軟件開發(fā)有一定的認(rèn)識,了解并掌握開發(fā)的各個流程,以及各功能代碼的實現(xiàn)。創(chuàng)建一個圖書館管理系統(tǒng),可進(jìn)行還書(插入),排序,查找,借書(刪除)操作。設(shè)計原理
2、:所有信息存儲在一個帶頭結(jié)點的單向鏈表中,每個結(jié)點存儲一條圖書記錄,即結(jié)構(gòu)體(book),其中各域為:書號(number)、書名(title)、作者(writer)、定價(pricing)、出版社(publishinghouse),指針域(next)。系統(tǒng)初始時圖書記錄為空,由用戶錄入信息,進(jìn)行插入(包括創(chuàng)建),排序,查找,刪除操作有兩種排序算法可選:選擇排序和直接插入排序,均由鏈表實現(xiàn)如輸入有錯,給出出錯提示工作計劃及安排:設(shè)計工作6學(xué)時實現(xiàn)與調(diào)試18學(xué)時課程設(shè)計說明書6學(xué)時指導(dǎo)教師簽字年 月 日 課程設(shè)計(大作業(yè))成績學(xué)號:20111101 姓名 指導(dǎo)教師:王亞寧課程設(shè)計題目:小型圖書館管
3、理系統(tǒng)總結(jié):在實驗中我學(xué)會了和同學(xué)一起合作,共同實現(xiàn)一個系統(tǒng)的編寫,我們分工合作,共同完成了在這次課程設(shè)計中讓我的編程能力得到了一定的提高,讓我熟悉了鏈表的一些操作,但在這個過程中還是有很多地方難以下手,需要同學(xué)的幫助。在這個過程中我更加的懂得了團結(jié)合作的重要性,學(xué)到了很多課本上學(xué)不到的東西,并且也鍛煉了我的溝通協(xié)調(diào)能力,相信我會在這樣每次的實踐活動中提升自己!指導(dǎo)教師評語:成績:填表時間:指導(dǎo)教師簽名:課程設(shè)計(大作業(yè))報告一、 題目分析 本題是一個圖書館管理系統(tǒng),涉及到c語言的一些基本操作,比如,構(gòu)造結(jié)構(gòu)體,插入,查找等!這個程序包括構(gòu)造一個結(jié)構(gòu)體,域為:書號,書名,作者,出版商,出版日期
4、。運用文件操作的方式實現(xiàn)文件的保存與調(diào)用!用菜單界面來操作整個過程!先寫每個功能的程序,然后再組合起來,這樣顯得調(diào)理清晰,不容易亂!二、 基本理論 C語言的基本知識,比如結(jié)構(gòu)體的構(gòu)造,鏈表的操作,文件的操作三、 總體設(shè)計函數(shù)功能:struct books_list * Create_Books_Doc(); /*新建鏈表*/void InsertDoc(struct books_list * head); /*插入*/void DeleteDoc(struct books_list * head , int num);/*刪除*/void Print_Book_Doc(struct books
5、_list * head);/*瀏覽*/void search_book(struct books_list * head); /*查詢*/void info_change(struct books_list * head);/*修改*/void save(struct books_list * head);/*保存數(shù)據(jù)至文件*/主函數(shù)main菜單menustuct book結(jié)構(gòu)體vid Print_Book()顯示書籍信息vid InsertDoc()輸入圖書信息voidsearch_name()search_isbn()查找 VoidDeleteDoc()刪除圖書信息voidesave()
6、保存數(shù)據(jù)置文件四、 實驗器材Pc機五、 方法步驟1. 創(chuàng)建主函數(shù)main()2新建數(shù)據(jù)文件create() 2.1為節(jié)點分配內(nèi)存 2.2創(chuàng)建二進(jìn)制文件用于存儲圖書信息 2.3通過一個循環(huán) 一次錄入圖書信息 2.4關(guān)閉文件3.編寫刪除數(shù)據(jù)紀(jì)錄函數(shù)delete() 3.1打開文件 3.2遍歷文件找到與指定圖書信息匹配的記錄 并刪除 3.3關(guān)閉文件4. 編寫瀏覽數(shù)據(jù)記錄函數(shù)Print_Book_Doc()4.1打開文件4.2遍歷整個數(shù)據(jù)。并顯示在于界面上 4.3保存數(shù)據(jù)至文件5建立查詢函數(shù)search_book() 5.1打開文件 5.2遍歷整個文件找到與指定圖書匹配信息 5.3輸出查詢到的信息 5
7、.4關(guān)閉文件6. 編寫修改數(shù)據(jù)紀(jì)錄函數(shù)info_change() 6.1打開文件 6.2遍歷整個文件找到與指定圖書信息匹配的記錄并修改 6.3關(guān)閉文件7.保存后結(jié)束整個程序六、成效分析我編寫的部分struct books_list char author20; /*作者名*/ char bookname20; /*書名*/ char publisher20; /*出版單位*/ char pbtime15; /*出版時間*/ char loginnum10; /*登陸號*/ float price; /*價格*/ char classfy10; /*分類號*/ struct books_list
8、 * next; /*鏈表的指針域*/;struct books_list * Create_Books_Doc(); /*新建鏈表*/void InsertDoc(struct books_list * head); /*插入*/void DeleteDoc(struct books_list * head , int num);/*刪除*/void Print_Book_Doc(struct books_list * head);/*瀏覽*/void search_book(struct books_list * head); /*查詢*/void info_change(struct b
9、ooks_list * head);/*修改*/void save(struct books_list * head);/*保存數(shù)據(jù)至文件*/*新建鏈表頭節(jié)點*/struct books_list * Create_Books_Doc() struct books_list * head; head=(struct books_list *)malloc(sizeof(struct books_list); /*分配頭節(jié)點空間*/ head->next=NULL; /*頭節(jié)點指針域初始化,定為空*/ return head;/*保存數(shù)據(jù)至文件*/void save(struct book
10、s_list * head) struct books_list *p; FILE *fp; p=head; fp=fopen("data.txt","w+"); /*以寫方式新建并打開 data.txt文件*/ fprintf(fp,"n"); /*向文件輸出表格*/ fprintf(fp,"登錄號 書 名 作 者 出版單位 出版時間 分類號 價格 n"); fprintf(fp,"n"); /*指針從頭節(jié)點開始移動,遍歷至尾結(jié)點,依次輸出圖書信息*/ while(p->next!= N
11、ULL) p=p->next; fprintf(fp,"%-6.6s%-10.10s%-10.10s%-10.10s%-12.12s%-6.6s%.2f n",p->loginnum,p->bookname,p->author,p->publisher,p->pbtime,p->classfy,p->price); fprintf(fp,"n"); fclose(fp); printf(" 已將圖書數(shù)據(jù)保存到 data.txt 文件n");/*插入*/void InsertDoc(str
12、uct books_list *head) /*定義結(jié)構(gòu)體指針變量 s指向開辟的新結(jié)點首地址 p為中間變量*/ struct books_list *s, *p; char flag='Y' /*定義flag,方便用戶選擇重復(fù)輸入*/ p=head; /*遍歷到尾結(jié)點,p指向尾結(jié)點*/ while(p->next!= NULL) p=p->next; /*開辟新空間,存入數(shù)據(jù),添加進(jìn)鏈表*/ while(flag='Y'|flag='y') s=(struct books_list *)malloc(sizeof(struct boo
13、ks_list); printf("n 請輸入圖書登陸號:"); fflush(stdin); scanf("%s",s->loginnum); printf("n 請輸入圖書書名:"); fflush(stdin); scanf("%s",s->bookname); printf("n 請輸入圖書作者名:"); fflush(stdin); scanf("%s",s->author); printf("n 請輸入圖書出版社:"); ff
14、lush(stdin); scanf("%s",s->publisher); printf("n 請輸入圖書出版時間:"); fflush(stdin); scanf("%s",s->pbtime); printf("n 請輸入圖書分類號:"); fflush(stdin); scanf("%s",s->classfy); printf("n 請輸入圖書價格:"); fflush(stdin); scanf("%f",&s->
15、;price); printf("n"); p->next=s; /*將新增加的節(jié)點添加進(jìn)鏈表*/ p=s; /*p指向尾節(jié)點,向后移*/ s->next=NULL; printf(" 添加成功!"); printf("n 繼續(xù)添加?(Y/N):"); fflush(stdin); scanf("%c",&flag); printf("n"); if(flag='N'|flag='n') break; else if(flag='Y
16、39;|flag='y') continue; save(head); /*保存數(shù)據(jù)至文件*/ return;/*修改操作*/void info_change(struct books_list * head) struct books_list * p; int panduan=0; /*此變量用于判斷是否找到書目*/ char temp20; p=head; printf("請輸入要修改的書名:"); scanf("%s",temp); while(p->next!= NULL) p=p->next; if(strcmp(
17、p->bookname,temp)=0) printf("n 請輸入圖書登陸卡號:"); fflush(stdin); scanf("%s",p->loginnum); printf("n 請輸入圖書書名:"); fflush(stdin); scanf("%s",p->bookname); printf("n 請輸入圖書作者名:"); fflush(stdin); scanf("%s",p->author); printf("n 請輸入圖書
18、出版社:"); fflush(stdin); scanf("%s",p->publisher); printf("n 請輸入圖書出版時間:"); fflush(stdin); scanf("%s",p->pbtime); printf("n 請輸入圖書分類號:"); fflush(stdin); scanf("%s",p->classfy); printf("n 請輸入圖書價格:"); fflush(stdin); scanf("%f&q
19、uot;,&p->price); printf("n"); panduan=1; if(panduan=0) printf("n 沒有圖書記錄! nn"); return;/*刪除操作*/void DeleteDoc(struct books_list * head) struct books_list *s,*p; /*s為中間變量,p為遍歷時使用的指針*/ char temp20; int panduan; /*此變量用于判斷是否找到了書目*/ panduan=0; p=s=head; printf(" 請輸入您要刪除的書名:
20、"); scanf("%s",temp); /*遍歷到尾結(jié)點*/ while(p!= NULL) if(strcmp(p->bookname,temp)=0) panduan+; break; p=p->next; if(panduan=1) for(;s->next!=p;) /*找到所需刪除卡號結(jié)點的上一個結(jié)點*/ s=s->next; s->next=p->next; /*將后一節(jié)點地址賦值給前一節(jié)點的指針域*/ free(p); printf("n 刪除成功! n"); else /*未找到相應(yīng)書目*
21、/ printf(" 您輸入的書目不存在,請確認(rèn)后輸入!n"); return;int main(void) struct books_list * head; char choice; head=NULL; for(;) /*實現(xiàn)反復(fù)輸入選擇*/ printf(" n"); printf(" socat 圖書管理系統(tǒng) n"); printf(" n"); printf(" 1圖書信息錄入 n"); printf(" n"); printf(" 2圖書信息瀏覽 n&
22、quot;); printf(" n"); printf(" 3圖書信息查詢 n"); printf(" n"); printf(" 4圖書信息修改 n"); printf(" n"); printf(" 5圖書信息刪除 n"); printf(" n"); printf(" 6退出系統(tǒng) n"); printf(" n"); printf(" 請選擇:"); fflush(stdin); scan
23、f("%c",&choice); if(choice='1') if(head=NULL) head=Create_Books_Doc(); InsertDoc(head); else if(choice='2') Print_Book_Doc(head); else if(choice='3') search_book(head); else if(choice='4') info_change(head); else if(choice='5') DeleteDoc(head); e
24、lse if(choice='6') printf("n"); printf(" 感謝使用圖書管理系統(tǒng) n"); break; else printf(" 輸入錯誤,請重新輸入!"); break; return 0; 程序源代碼#include<stdio.h>#include<math.h>#include<string.h>#include<stdlib.h>struct books_list char author20; /*作者名*/ char bookname
25、20; /*書名*/ char publisher20; /*出版單位*/ char pbtime15; /*出版時間*/ char loginnum10; /*登陸號*/ float price; /*價格*/ char classfy10; /*分類號*/ struct books_list * next; /*鏈表的指針域*/;struct books_list * Create_Books_Doc(); /*新建鏈表*/void InsertDoc(struct books_list * head); /*插入*/void DeleteDoc(struct books_list * h
26、ead , int num);/*刪除*/void Print_Book_Doc(struct books_list * head);/*瀏覽*/void search_book(struct books_list * head); /*查詢*/void info_change(struct books_list * head);/*修改*/void save(struct books_list * head);/*保存數(shù)據(jù)至文件*/*新建鏈表頭節(jié)點*/struct books_list * Create_Books_Doc() struct books_list * head; head=(
27、struct books_list *)malloc(sizeof(struct books_list); /*分配頭節(jié)點空間*/ head->next=NULL; /*頭節(jié)點指針域初始化,定為空*/ return head;/*保存數(shù)據(jù)至文件*/void save(struct books_list * head) struct books_list *p; FILE *fp; p=head; fp=fopen("data.txt","w+"); /*以寫方式新建并打開 data.txt文件*/ fprintf(fp,"n")
28、; /*向文件輸出表格*/ fprintf(fp,"登錄號 書 名 作 者 出版單位 出版時間 分類號 價格 n"); fprintf(fp,"n"); /*指針從頭節(jié)點開始移動,遍歷至尾結(jié)點,依次輸出圖書信息*/ while(p->next!= NULL) p=p->next; fprintf(fp,"%-6.6s%-10.10s%-10.10s%-10.10s%-12.12s%-6.6s%.2f n",p->loginnum,p->bookname,p->author,p->publisher,
29、p->pbtime,p->classfy,p->price); fprintf(fp,"n"); fclose(fp); printf(" 已將圖書數(shù)據(jù)保存到 data.txt 文件n");/*插入*/void InsertDoc(struct books_list *head) /*定義結(jié)構(gòu)體指針變量 s指向開辟的新結(jié)點首地址 p為中間變量*/ struct books_list *s, *p; char flag='Y' /*定義flag,方便用戶選擇重復(fù)輸入*/ p=head; /*遍歷到尾結(jié)點,p指向尾結(jié)點*/
30、while(p->next!= NULL) p=p->next; /*開辟新空間,存入數(shù)據(jù),添加進(jìn)鏈表*/ while(flag='Y'|flag='y') s=(struct books_list *)malloc(sizeof(struct books_list); printf("n 請輸入圖書登陸號:"); fflush(stdin); scanf("%s",s->loginnum); printf("n 請輸入圖書書名:"); fflush(stdin); scanf(&qu
31、ot;%s",s->bookname); printf("n 請輸入圖書作者名:"); fflush(stdin); scanf("%s",s->author); printf("n 請輸入圖書出版社:"); fflush(stdin); scanf("%s",s->publisher); printf("n 請輸入圖書出版時間:"); fflush(stdin); scanf("%s",s->pbtime); printf("n
32、請輸入圖書分類號:"); fflush(stdin); scanf("%s",s->classfy); printf("n 請輸入圖書價格:"); fflush(stdin); scanf("%f",&s->price); printf("n"); p->next=s; /*將新增加的節(jié)點添加進(jìn)鏈表*/ p=s; /*p指向尾節(jié)點,向后移*/ s->next=NULL; printf(" 添加成功!"); printf("n 繼續(xù)添加?(Y/N
33、):"); fflush(stdin); scanf("%c",&flag); printf("n"); if(flag='N'|flag='n') break; else if(flag='Y'|flag='y') continue; save(head); /*保存數(shù)據(jù)至文件*/ return;/*查詢操作*/void search_book(struct books_list *head) struct books_list * p; char temp20; p=h
34、ead; if(head=NULL | head->next=NULL) /*判斷數(shù)據(jù)庫是否為空*/ printf(" 圖書庫為空!n"); else printf("請輸入您要查找的書名: "); fflush(stdin); scanf("%s",temp); /*指針從頭節(jié)點開始移動,遍歷至尾結(jié)點,查找書目信息*/ while(p->next!= NULL) p=p->next; if(strcmp(p->bookname,temp)=0) printf("n圖書已找到!n"); pr
35、intf("n"); printf("登錄號: %stn",p->loginnum); printf("書名: %stn",p->bookname); printf("作者名: %stn",p->author); printf("出版單位: %stn",p->publisher); printf("出版時間: %stn",p->pbtime); printf("分類號: %stn",p->classfy); printf
36、("價格: %.2ftn",p->price); if(p->next=NULL) printf("n查詢完畢!n"); return; /*瀏覽操作*/void Print_Book_Doc(struct books_list * head) struct books_list * p; if(head=NULL | head->next=NULL) /*判斷數(shù)據(jù)庫是否為空*/ printf("n 沒有圖書記錄! nn"); return; p=head; printf("n"); printf
37、("登錄號 書 名 作 者 出版單位 出版時間 分類號 價格 n"); printf("n"); /*指針從頭節(jié)點開始移動,遍歷至尾結(jié)點,依次輸出圖書信息*/ while(p->next!= NULL) p=p->next; printf("%-6.6s%-10.10s%-10.10s%-10.10s%-12.12s%-6.6s%.2f n",p->loginnum,p->bookname,p->author,p->publisher,p->pbtime,p->classfy,p->
38、;price); /*循環(huán)輸出表格*/ printf("n"); printf("n");/*修改操作*/void info_change(struct books_list * head) struct books_list * p; int panduan=0; /*此變量用于判斷是否找到書目*/ char temp20; p=head; printf("請輸入要修改的書名:"); scanf("%s",temp); while(p->next!= NULL) p=p->next; if(strcm
39、p(p->bookname,temp)=0) printf("n 請輸入圖書登陸卡號:"); fflush(stdin); scanf("%s",p->loginnum); printf("n 請輸入圖書書名:"); fflush(stdin); scanf("%s",p->bookname); printf("n 請輸入圖書作者名:"); fflush(stdin); scanf("%s",p->author); printf("n 請輸入
40、圖書出版社:"); fflush(stdin); scanf("%s",p->publisher); printf("n 請輸入圖書出版時間:"); fflush(stdin); scanf("%s",p->pbtime); printf("n 請輸入圖書分類號:"); fflush(stdin); scanf("%s",p->classfy); printf("n 請輸入圖書價格:"); fflush(stdin); scanf("%f
41、",&p->price); printf("n"); panduan=1; if(panduan=0) printf("n 沒有圖書記錄! nn"); return;/*刪除操作*/void DeleteDoc(struct books_list * head) struct books_list *s,*p; /*s為中間變量,p為遍歷時使用的指針*/ char temp20; int panduan; /*此變量用于判斷是否找到了書目*/ panduan=0; p=s=head; printf(" 請輸入您要刪除的書名:"); scanf("%s",temp); /*遍歷到尾結(jié)點*/ while(p!= NULL) if(strcmp(p->bookname,temp)=0) panduan+; break; p=p->next; if(pa
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年淮陽縣招教考試備考題庫附答案解析
- 2025年徐州幼兒師范高等??茖W(xué)校馬克思主義基本原理概論期末考試模擬題及答案解析(必刷)
- 某紡織公司會員體系建設(shè)方案
- 2024年突泉縣幼兒園教師招教考試備考題庫及答案解析(必刷)
- 某服裝公司服裝展廳升級方案
- 2025年六盤水職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫帶答案解析
- 某家具公司家具咨詢服務(wù)方案(規(guī)則)
- 2025年鄰水縣招教考試備考題庫帶答案解析
- 2025年綿陽飛行職業(yè)學(xué)院馬克思主義基本原理概論期末考試模擬題附答案解析
- 2024年玉山縣招教考試備考題庫附答案解析(奪冠)
- 佛山市離婚協(xié)議書范本
- HG+20231-2014化學(xué)工業(yè)建設(shè)項目試車規(guī)范
- 工地春節(jié)停工復(fù)工計劃安排方案
- 中學(xué)檔案室管理職責(zé)范文(3篇)
- 產(chǎn)品年度質(zhì)量回顧分析
- 連接員題庫(全)題庫(855道)
- 單元學(xué)習(xí)項目序列化-選擇性必修下冊第三單元為例(主題匯報課件)-統(tǒng)編高中語文教材單元項目式序列化研究
- 黑布林英語漁夫和他的靈魂
- 電站組件清洗措施及方案
- 冀教版五年級英語下冊全冊同步練習(xí)一課一練
- 城鎮(zhèn)土地估價規(guī)程
評論
0/150
提交評論