學生借閱系統(tǒng)課程設計_第1頁
學生借閱系統(tǒng)課程設計_第2頁
學生借閱系統(tǒng)課程設計_第3頁
學生借閱系統(tǒng)課程設計_第4頁
學生借閱系統(tǒng)課程設計_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、課程設計(大作業(yè))報告課程名稱:程序設計語言 設計題目:學生借閱系統(tǒng) 院 系:自動化控制與機械工程學院班 級:機制(2)班設 計 者:遲寬廣 龔正雄 譚小春學 號:201204100203201204100207201204100228指導教師:趙卿設計時間:2013-7-12013-7-12昆明學院課程設計(大作業(yè))任務書姓 名:遲寬廣 龔正雄 譚小春院(系):自機學院專 業(yè):機械設計制造及其自動化學 號:201204100203 、201204100207、201204100228任務起止日期:2013-7-12013-7-12課程設計題目:學生借閱系統(tǒng)課程設計要求: 設計一個學生借閱系統(tǒng)

2、,功能包括:學生管理子系統(tǒng),由管理員負責錄入信息(包括學號、姓名、學院名、圖書名等信息),刪除學生信息等功能;學生借閱子系統(tǒng)(保存用戶名、借閱書的編號、書名等信息),負責學生借閱、歸還、續(xù)借、超期罰款等功能;查詢子系統(tǒng),包括可以查詢學生庫中的借閱圖書、學生借閱情況等,信息保存到文件中。工作計劃及安排:第十八周:問題分析,方案設計,軟件編碼和調試;第19周: 軟件測試,書寫課程實驗設計報告,答辯。指導教師簽字2013年7月 9 日 課程設計(大作業(yè))成績學號:201204100203姓名:遲寬廣指導教師:趙卿課程設計題目:學生借閱系統(tǒng)總結:通過一段時間的編程實踐,使我c語言的知識了解的更加深刻,

3、知識面更加寬廣。同時,在編程實踐中遇到了很多困難,明顯的了解到自己知識運用能力的不足,通過查書和與同學交流,使我取得了很大的進步。指導教師評語:成績:123456填表時間:指導教師簽名:課程設計(大作業(yè))報告一、 題目分析設計一個學生借閱系統(tǒng),功能包括:學生管理子系統(tǒng),由管理員負責錄入信息(包括學號、姓名、學院名、圖書名等信息),刪除學生信息等功能;學生借閱子系統(tǒng)(保存用戶名、借閱書的編號、書名等信息),負責圖書的借閱、歸還、續(xù)借、超期罰款等功能;查詢子系統(tǒng),包括可以查詢學生庫中的書、學生借閱情況等;信息保存到文件中。二、 基本理論1, 建立一個關于圖書的結構體,內含ISBN號,書名,作者,出

4、版社和價格。2, InsertDoc函數,負責新書信息的插入。3, void sort_maopao函數,用冒泡法將圖書的ISBN號以由小到大的順序進行排列。 4, void DeleteDoc函數,將廢舊圖書信息進行刪除。5, void Print_Book_Doc函數,輸出圖書的信息,方便讀者選書。6, void search_book函數,進行圖書的查詢。7, void info_change函數,將圖書信息進行修改。8, 主函數,用switch-case結構進行函數的調用。三、 總體設計1、 軟件模塊設計學生借閱系統(tǒng)學生排序學生借閱學生信息刪除學生信息查詢學生信息修改學生信息瀏覽學生信

5、息錄入 圖2-2-12、軟件界面設計 圖2-3-1四、 實驗器材開發(fā)工具:Visual C+ 6.0, CodeBlock10.05,等環(huán)境:Windows 7操作系統(tǒng)。五、 方法步驟(程序調試)1 調試方案選擇1,輸入201204100203 遲寬廣 自機學院鋼鐵事怎樣煉成的 001201204100207 龔正雄自機學院成功的男人 002 201204100228 譚小春自機學院愛情三十六計 003選擇2,輸出圖3-2-1選擇7,輸出圖3-2-22. 調試結果 圖3-2-1圖3-2-2六、 成效分析在編程實踐中,我才知道自己基礎知識的不足,通過一段時間的努力學習,我的基礎知識更加牢固,尤其

6、是后面指針,結構體,鏈表,文件的知識了解的更加深入。其次是知識的運用,以前學到的知識都是片面的了解,一到編程序時就無從下手,現在能熟練的應用各種知識,使知識得到應用。最后是編程的技巧,從整體構型到各個函數的應用都有了很大的進步。七、 參考文獻1c語言程序設計,馬秀麗,李筠著。清華大學出版社.2008.12c程序設計(第三版),譚浩強著,清華大學出版社.2005.73面向對象程序設計(c+語言),李愛華,程磊著,清華大學出版社.2010,2八、源代碼#include<stdio.h>#include<math.h>#include<string.h>#incl

7、ude<stdlib.h>struct books_list char writer20; /*學院名*/ char title20; char ISBN20; /*姓名*/ char publishinghouse20; /*圖書名*/ int price,borrowed; /*圖書編號*/ struct books_list * next; /*鏈表的指針域*/;struct books_list * Create_Books_Doc(); /*新建鏈表*/void InsertDoc(struct books_list * head); /*插入*/void sort_ma

8、opao(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 books_list * head); /*修改*/void save(struct books_list * head); /*保存數據至文件*/ /*新

9、建鏈表頭節(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; /*保存數據至文件*/void save(struct books_list * head) struct books_list *p; FILE *fp; p=head; fp=fopen("da

10、ta.txt","w+"); /*以寫方式新建并打開 data.txt文件*/ fprintf(fp," -學 號-姓 名-學 院 名-圖 書 名-借 閱 圖 書 編 號 n"); /*指針從頭節(jié)點開始移動,遍歷至尾結點,依次輸出學生借閱信息*/ while(p->next!= NULL) p=p->next; fprintf(fp,"%-6.6s %-15.10s %-10.10s %-10.10s %-10.10dn",p->ISBN,p->title,p->writer,p->pub

11、lishinghouse,p->price); fprintf(fp,"n"); fclose(fp); printf(" 已將學生數據保存到 data.txt 文件n");void sort_maopao(struct books_list * head ) struct books_list *tail,*p,*q,*p1,*t; /p1等于head t等于head q保存p的next節(jié)點 p1=(struct books_list *)malloc(sizeof (struct books_list); for(t=head->next

12、;t!=NULL;t=t->next) for(p=head->next,p1=head;p->next!=NULL;p=p->next,p1=p1->next) if(strcmp(p->ISBN,p->next->ISBN)>0) q=p->next->next; tail=p->next; tail->next=NULL; p->next=q; p1->next=tail; tail->next=p; p=p1; save(head); /保存文件/*插入*/void InsertDoc(st

13、ruct books_list *head) /*定義結構體指針變量 s指向開辟的新結點首地址 p為中間變量*/ struct books_list *s, *p; char flag='Y' /*定義flag,方便用戶選擇重復輸入*/ p=head; /*遍歷到尾結點,p指向尾結點*/ while(p->next!= NULL) p=p->next; /*開辟新空間,存入數據,添加進鏈表*/ while(flag='Y'|flag='y') system("cls"); p->borrowed=0; s=(

14、struct books_list *)malloc(sizeof(struct books_list); printf("n 請輸入學生學號:"); fflush(stdin); scanf("%s",s->ISBN); printf("n 請輸入學生姓名:"); fflush(stdin); scanf("%s",s->title); printf("n 請輸入學生學院名:"); fflush(stdin); scanf("%s",s->writer);

15、 printf("n 請輸入借閱圖書名:"); fflush(stdin); scanf("%s",s->publishinghouse); printf("n 請輸入借閱圖書編號:"); fflush(stdin); scanf("%d",&s->price); printf("n"); p->next=s; /*將新增加的節(jié)點添加進鏈表*/ p=s; /*p指向尾節(jié)點,向后移*/ s->next=NULL; printf(" 添加成功!")

16、; printf("n 繼續(xù)添加?(Y/N):"); fflush(stdin); scanf("%c",&flag); printf("n"); if(flag='N'|flag='n') break; else if(flag='Y'|flag='y') continue; save(head); /*保存數據至文件*/ system("cls"); return;/*查詢操作*/void search_book(struct books_

17、list *head) struct books_list * p; char temp20; p=head; if(head=NULL | head->next=NULL) /*判斷數據庫是否為空*/ printf(" 學生庫為空!n"); else printf("請輸入您要查找的書名: "); fflush(stdin); scanf("%s",temp); /*指針從頭節(jié)點開始移動,遍歷至尾結點,查找學生借閱信息*/ while(p->next!= NULL) p=p->next; if(strcmp(p-&

18、gt;title,temp)=0) printf("n學生信息已找到!n"); printf("n"); printf("學號: %stn",p->ISBN); printf("姓名: %stn",p->writer); printf("學院名: %stn",p->writer); printf("圖書名: %stn",p->publishinghouse); printf("圖書編號: %.2dtn",p->price);

19、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) /*判斷數據庫是否為空*/ printf("n 沒有學生借閱記錄! nn"); return; p=head; printf("nnntt學號 姓名 學院名 圖書名 圖書編號 n"); /*指針從頭節(jié)點開始移動,遍歷至尾結

20、點,依次輸出學生借閱信息*/ while(p->next!= NULL) p=p->next; printf("tt%-7.6s %-13.10s %-10.10s %-10.10s %d n",p->ISBN,p->title,p->writer,p->publishinghouse,p->price); printf("n");/*修改操作*/void info_change(struct books_list * head) struct books_list * p; int panduan=0; /*此

21、變量用于判斷是否找到學生信息*/ char temp20; p=head; printf("請輸入要修改的姓名:"); scanf("%s",temp); while(p->next!= NULL) p=p->next; if(strcmp(p->title,temp)=0) printf("n 請輸入學生學號:"); fflush(stdin); scanf("%d",p->ISBN); printf("n 請輸入學生姓名:"); fflush(stdin); scan

22、f("%s",p->title); printf("n 請輸入學生學院名:"); fflush(stdin); scanf("%s",p->writer); printf("n 請輸入圖書名:"); fflush(stdin); scanf("%s",p->publishinghouse); printf("n 請輸入借閱圖書編號:"); fflush(stdin); scanf("%d",&p->price); print

23、f("n"); panduan=1; if(panduan=0) printf("n 沒有學生借閱記錄! nn"); return;void book_borrow(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->nex

24、t; if(strcmp(p->title,temp)=0)&&(p->borrowed=0) p->borrowed=1; panduan=1; printf("借閱成功 n"); if(panduan=0) printf("n 沒有該學生信息! nn"); return;/*刪除操作*/void DeleteDoc(struct books_list * head) struct books_list *s,*p; /*s為中間變量,p為遍歷時使用的指針*/ char temp20; int panduan; /*此

25、變量用于判斷是否找到了學生信息*/ panduan=0; p=s=head; printf(" 請輸入您要刪除的姓名:"); scanf("%s",temp); /*遍歷到尾結點*/ while(p!= NULL) if(strcmp(p->title,temp)=0) panduan+; break; p=p->next; if(panduan=1) for(;s->next!=p;) /*找到所需刪除卡號結點的上一個結點*/ s=s->next; s->next=p->next; /*將后一節(jié)點地址賦值給前一節(jié)點的指針域*/ free(p); printf("n 刪除成功! n"); else /*未找到相應學生姓名*/ printf(" 您輸入的姓名不存在,請確認后輸入!n"); return;int main(void) struct books_list * head; int c

溫馨提示

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

評論

0/150

提交評論