![程序課程設計圖書管理系統(tǒng)_第1頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/4/43606da6-cceb-4352-9d67-83af5bd633e1/43606da6-cceb-4352-9d67-83af5bd633e11.gif)
![程序課程設計圖書管理系統(tǒng)_第2頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/4/43606da6-cceb-4352-9d67-83af5bd633e1/43606da6-cceb-4352-9d67-83af5bd633e12.gif)
![程序課程設計圖書管理系統(tǒng)_第3頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/4/43606da6-cceb-4352-9d67-83af5bd633e1/43606da6-cceb-4352-9d67-83af5bd633e13.gif)
![程序課程設計圖書管理系統(tǒng)_第4頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/4/43606da6-cceb-4352-9d67-83af5bd633e1/43606da6-cceb-4352-9d67-83af5bd633e14.gif)
![程序課程設計圖書管理系統(tǒng)_第5頁](http://file2.renrendoc.com/fileroot_temp3/2021-11/4/43606da6-cceb-4352-9d67-83af5bd633e1/43606da6-cceb-4352-9d67-83af5bd633e15.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、程序設計課程設計報告圖書管理系統(tǒng)專業(yè)計算機科學與技術(shù)學生姓名于露班級b計123學號1210704324指導教師張靜林完成日期2013年6月1 課程設計的目的1. 加強對c語言程序設計課程知識的理解,掌握c語言應用程序的開發(fā)方法和步驟2. 進一步掌握和利用c語言進行程序設計的能力3. 進一步理解和運用結(jié)構(gòu)化程序設計的思想和方法4. 初步掌握開發(fā)一個小型實用系統(tǒng)的基本方法5. 學會調(diào)試一個較長程序的基本方法6. 學會利用流程圖或n-s圖表示算法7. 掌握書寫程序設計開發(fā)文檔的能力(書寫課程設計報告)2 課程設計任務3 課程設計課題課題1:圖書管理系統(tǒng)總體程序框圖系統(tǒng)的總體流程圖開始編譯運行main
2、 打開文件數(shù)據(jù)讀入結(jié)構(gòu)體中執(zhí)行選擇 調(diào)用不同函數(shù)程序# include <stdio.h># include <string.h># include <stdlib.h>struct list char num20 ; /*圖書編號*/ char name40 ; /*書名*/ char author40 ; /*作者*/ char publish 40; /*出版社*/ double price ; /*價格*/;struct list b40 ;int w=0; /*定義一個全局變量,用來記錄bookinfo.txt文件中的數(shù)據(jù)個數(shù)*/void sear
3、ch_allinformation(struct list b) ; /*查看全部圖書信息*/void check_bookinformation (struct list b ); /*查找圖書信息*/void add_bookinformation (struct list b ); /*添加圖書信息*/void delete_bookinformation (struct list b ); /*刪除圖書信息*/void borrow_book (struct list b ) ; /*借閱圖書*/int main () int i = 0 ; int choice1; file *fp
4、 ; printf(" * * *n"); printf(" * 歡迎進入圖書館信息管理系統(tǒng) *n"); printf(" * * *n"); fp = fopen ("e:bookinfo.txt" , "r") ; if(fp = null) printf("can not open the file !n") ; exit (0) ; while (! feof(fp) fscanf(fp,"%s%s%s%s%lf" , /*調(diào)用函數(shù)將文件中的數(shù)據(jù)讀
5、入結(jié)構(gòu)變量中*/ bi.num,,bi.author,bi.publish,&bi.price) ; i+ ; w=i-1; fclose (fp) ; do printf("#");printf(" 功能選項: n");printf(" 1:查看全部圖書信息 n") ;printf(" 2:查找圖書信息 n") ;printf(" 3:添加圖書信息 n") ;printf(" 4:刪除圖書信息 n") ;printf(" 5:借閱圖書 n&q
6、uot;) ;printf(" 0:退出系統(tǒng) n") ;printf("#");printf("請選擇操作:"); scanf("%d" , &choice1); switch (choice1) case 1 : search_allinformation (b); break ; case 2 : check_bookinformation( b ); break ; case 3 : add_bookinformation (b ); break ; case 4 : delete_bookinfor
7、mation( b); break ; case 5 : borrow_book( b); break ; case 0 : break ;while (choice1 != 0); printf("謝謝使用!n"); return 0; /*查看全部圖書信息*/void search_allinformation (struct list b)int i; printf(" #n"); printf(" # 查看全部圖書信息! #n"); printf(" #n"); printf("圖書的相關(guān)信息:
8、編號 書名 作者 出版社 價格n"); for(i=0;i<w;i+) printf(" %s %s %s %s %.2fn", /*將數(shù)據(jù)輸出到屏幕中*/ bi.num, , bi.author, bi.publish, bi.price); printf("%d " , w); printf("#n"); /*查找圖書信息*/void check_bookinformation(struct list b )int i, flag=0;char s20; printf("輸入編號:n&quo
9、t;) ; /*提示輸入圖書編號*/ scanf("%s" , s); printf(" #n"); printf(" # 查找圖書信息! #n"); printf(" #n"); for(i=0;i<w;i+) if (strcmp(s, bi.num)=0) printf("該圖書的相關(guān)信息: 編號 書名 作者 出版社 價格n"); printf(" %s %s %s %s %.2fn", bi.num, , bi.author, bi.publish
10、, bi.price); flag = 1; break; if (flag = 0) printf("該圖書編號不存在!n"); printf("是否要繼續(xù)查找? y:是 ; n:否n") ; getchar(); switch(getchar()case 'y': check_bookinformation( b ) ; /*調(diào)用函數(shù)本身繼續(xù)查找*/case 'n' : break ; printf("#n");/*添加圖書信息*/void add_bookinformation(struct li
11、st b ) int i, count=0, choice3; struct list p ;file *fp2 ; printf(" #n"); printf(" # 添加圖書信息! #n"); printf(" #n"); printf("請輸入該圖書的相關(guān)信息:n") ; printf("編號 書名 作者 出版社 價格n"); scanf(" %s %s %s %s %lf", p.num , ,p.author,p.publish,&p.price
12、); printf(" 添加成功 !n"); printf(" 是否顯示添加后的信息? 1:是 ; 2:否 n"); printf(" 請選擇:"); scanf("%d" , &choice3); switch (choice3) case 1 : for(i=0;i<w;i+) if(strcmp(p.num,bi.num)>0) count + ; for(i=w;i>count;i-) bi = bi-1 ; bi = p ; w+; /*每添加一本圖書,圖書數(shù)目都會增加一個*/
13、fp2 = fopen ("e:bookinfo.txt" , "w") ; if(fp2 = null) printf("can not open the file !n"); exit (0) ; for(i=0;i<w;i+) fprintf(fp2," %s %s %s %s %.2fn" , bi.num,,bi.author,bi.publish,bi.price); fclose (fp2) ; for(i=0;i<w;i+) printf(" %s %s %s %
14、s %.2fn" , bi.num,,bi.author,bi.publish,bi.price); case 2 : break ; printf("#n"); /*刪除圖書信息*/void delete_bookinformation (struct list b ) int i, flag= 0,choice4; char s20 ; printf(" #n"); printf(" # 刪除圖書信息 #n"); printf(" #n"); printf("請輸入圖書編號:&
15、quot;);scanf("%s", s); for(i=0;i<w;i+) if(strcmp(s,bi.num)=0) printf(" 刪除成功 !n"); printf(" 是否顯示刪除后的信息? 1:是 ; 2:否 n"); printf(" 請選擇:"); scanf("%d" , &choice4); switch (choice4) case 1 : printf("刪除后的圖書信息: 編號 書名 作者 出版社 價格n"); for(i=0;i&
16、lt;w;i+) if(strcmp(s,bi.num)!=0) printf(" %s %s %s %s %.2fn", bi.num, , bi.author, bi.publish, bi.price); case 2 : break ; flag = 1 ; break ; if(flag = 0)printf("該圖書編號不存在!n"); printf("#n"); /*借閱圖書*/void borrow_book(struct list b ) int i=0, n=0,flag=0, x=0;int m;
17、/*定義一個變量用來記錄sendinfo.txt文件中的數(shù)據(jù)個數(shù)*/struct list q;struct student char name20 ; char number40 ;struct student stu50 ; file *fp ; file *fp4 ; printf(" #n"); printf(" # 借閱圖書 #n"); printf(" #n"); a: printf("輸入圖書編號:"); scanf("%s" , q.num ); fp = fopen (&quo
18、t;e:bookinfo.txt" , "a") ; if(fp = null) printf("can not open the file !n"); exit (0) ; for(i=0;i<w;i+) if(strcmp(q.num , bi.num) =0) flag=1; if(flag=0) printf("該圖書編號不存在, 請重新輸入!n"); borrow_book( b ) ; fclose(fp) ; if(flag=1) fp4 = fopen ("e:sentinfo.txt&quo
19、t; , "r") ; if(fp4 = null) printf("can not open the file !n") ; exit (0) ; while (! feof(fp4) fscanf(fp4,"%s%s" , /*調(diào)用函數(shù)將文件中的數(shù)據(jù)讀入結(jié)構(gòu)變量中*/ stui.number,) ; i+ ; n=i-1; fclose (fp4) ; fp = fopen ("e:sentinfo.txt" , "a") ; if(fp = null) printf(&q
20、uot;can not open the file !n"); exit (0) ; for(i=0;i<n;i+) if(strcmp(q.num, stui.number) =0) printf("該圖書已借出!"); printf("是否繼續(xù)續(xù)借? y or nn"); getchar(); if(getchar()='y') goto a;else x = 1; if(x = 0) /*若該圖書未借出,則執(zhí)行以下操作*/ printf("請輸入學號: "); scanf("%d", &m); if(fp=fopen("e:sendinfo.txt","a") = null) printf("file open error!n"); exit(0); fprintf(fp," %s %d",q.num , m ); fclose(fp); printf(" 借閱成功!n
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- N-Nitroso-clonidine-生命科學試劑-MCE-2307
- IRF1-IN-1-生命科學試劑-MCE-6527
- 二零二五年度文化場館消毒防疫服務合同
- 二零二五年度電動助力車租賃與充電樁安裝合同
- 2025年度房屋買賣合同變更及產(chǎn)權(quán)過戶補充協(xié)議
- 2025年度理發(fā)店入股與客戶滿意度提升合作協(xié)議
- 施工現(xiàn)場施工防塌陷制度
- 施工單位關(guān)于施工設備的工作聯(lián)系函
- 綠色校園教學樓電氣節(jié)能與環(huán)保方案
- 食堂的應急預案
- GB/T 44143-2024科技人才評價規(guī)范
- 對醫(yī)院領導的批評意見怎么寫更合適范文(6篇)
- 賬期協(xié)議書賬期合同書
- 2024年常德職業(yè)技術(shù)學院單招職業(yè)適應性測試題庫完整
- 天津市河東區(qū)2023-2024學年九年級上學期期末數(shù)學試題
- 工程防滲漏培訓課件
- 黑龍江省哈爾濱市2024年數(shù)學八年級下冊期末經(jīng)典試題含解析
- 牛津3000核心詞匯表注釋加音標1-4 完整版
- 高中英語以讀促寫教學策略與實踐研究課件
- 金屬表面處理中的冷噴涂技術(shù)
- 河北省石家莊市2023-2024學年高一上學期期末教學質(zhì)量檢測化學試題(解析版)
評論
0/150
提交評論