C教務管理系統(tǒng)程序報告.doc_第1頁
C教務管理系統(tǒng)程序報告.doc_第2頁
C教務管理系統(tǒng)程序報告.doc_第3頁
C教務管理系統(tǒng)程序報告.doc_第4頁
C教務管理系統(tǒng)程序報告.doc_第5頁
已閱讀5頁,還剩28頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

二一二二一三學年第二學期信息科學與工程學院面向對象C+語言課程設計報告課程名稱: 面向對象C+語言課程設計 目 錄1.需求分析32.總體設計43.詳細設計54.調試測驗65.測試結果66.心得體會127.相關附錄13.需求分析(1)問題描述:設計一個學生信息管理系統(tǒng),能錄入、修改、添加、刪除、查詢、顯示學生信息。并將學生信息在文件中保存。(2)應用價值:能作為一個有效管理學生信息的系統(tǒng)??梢詢Υ鎸W生的姓名、學號、性別、年齡、住址、各科成績。這在現(xiàn)實中對學生信息的管理也有極其重要的應用價值??梢杂行У谋4鎸W生信息,應用于教務管理。(3)限制條件:因為剛接觸C語言不到,兩個學期。所以所做程序難免會有一些瑕疵。在次列舉其中的一些限制條件。我所設置的錄入學生信息的函數(shù)必須由學號由小到大錄入,這是為了配合后面的修改、添加、刪除查詢功能。因為后面幾個功能實現(xiàn)的方法就是由學號從小到達找所要修改的那一個結點。另一個問題就是學號的首位不可以為零,否則的話就無法顯示首位。對于這一問題,我還沒有想到更好的解決方法。不過在現(xiàn)實應用中,很少出現(xiàn)學號首位為零的情況。因此也就不會太影響使用價值。最后一個問題,就是如果輸入的數(shù)據(jù)類型與定義的不符,就可能引起系統(tǒng)崩潰。因此,用戶在錄入信息時應特別注意數(shù)據(jù)類別。總體設計(1) 程序設計組成框圖1、輸入學生的信息:姓名、性別、學號、地址、成績4、輸入要刪除的學生的學號,刪除學生信息 菜單1. 輸入學生信息2. 插入學生信息3. 修改學生信息4. 刪除學生信息5. 顯示學生信息6. 查詢學生信息7. 退出5、顯示學生的姓名、性別、學號、地址、成績2、輸入要插入學生的學號,填加信息6、輸入你要查找學生姓名或學號,修改學生信息3、按學生的學號或姓名來修改學生的相關信息7、退出系統(tǒng)學生信息管理系統(tǒng)功能模塊圖(2) 流程圖開 始輸入學生信息息生生信息修 改插 入刪 除查 詢退 出顯示結 束詳細設計函數(shù)功能student *creat(void)用于創(chuàng)建鏈表,不需要參數(shù),返回鏈表頭指針,在輸入學生信息時調用。student *del(student*,long)用于刪除結點,參數(shù)為頭指針及要刪除學生的學號,返回頭指針。在刪除學生信息時調用。 student *insert(student *,student *)用于插入結點,參數(shù)為頭指針及類的指針,返回頭指針。插入學生信息時調用。student *correct_num(student *,long)用于修改結點,參數(shù)為頭指針及學號,返回頭指針。按學號修改學生信息時調用。student *correct_nam(student *,string)按姓名修改學生信息時調用。student *search_num(student *,long)用于查找結點,參數(shù)為頭指針及學號,返回頭指針。按學號查找學生信息時調用。student *search_nam(student *,string) 用于查找結點,參數(shù)為頭指針及學號,返回頭指針。按姓名查找學生信息時調用。int save(student *head)用于將指針數(shù)據(jù)存放到文件中。 void print(student*)參數(shù)為頭指針,用于輸出各結點數(shù)據(jù)。調試測驗通過輸入學生信息,再修改、刪除、添加、查詢,最后輸出。檢查是否滿足預期結果,不滿足則重新完善。過程中也遇到許多問題。其中之一就是在執(zhí)行查詢、添加等功能是出現(xiàn)程序停止工作的情況。最后才發(fā)現(xiàn)在進行判斷時,將head=NULL誤輸為head=NULL,將鏈表轉化為了空鏈表,當然無法工作啦。在其他細節(jié)方面,也出現(xiàn)了類似的錯誤。因此,編程要特別仔細,一個小小的錯誤,都可能使整個程序毀于一旦。測試結果(1)首頁(2)輸入非選項中的的數(shù)字(3)錄入信息(4)插入信息(5)顯示信息(6)刪除信息(7)修改信息(8)查詢信息(9)查詢學生學號不存在時(10)顯示信息(11)退出系統(tǒng)心得體會耗時將近兩周的C+程序設計即將畫上句號。這也是我接觸過的最復雜的程序。要想一步完成如此繁瑣的程序是不可能的。因此必須有合理的規(guī)劃,列出框架。再分別用函數(shù)來實現(xiàn)各個功能。然后就是細化的工作,要分別設計各個函數(shù),這也是最關鍵的一步。既要注意各個函數(shù)的獨立性,又要注意他們之間的關系和在整個程序中的作用。最后將各不分有機結合為宜各整體。再通過不斷的調試、完善,最后達到預期的效果。當然,最困難的部分就是修改。面對一個個問題,你需要不斷的檢查,在繁雜的程序中發(fā)現(xiàn)那一個錯誤。這過程雖然是困難的,必須非常仔細,絞盡腦汁想各種錯誤的原因,最后解決問題。當問題被解決的那一刻,心中會由然而生出一種成就感。這也是程序設計帶給我的快樂。在今后的學習生活中,我將投入更多時間到C+程序設計中,這樣設計程序將會更加得心應手。程序設計就是這樣一門神奇的課程,只有勤于思考,刻苦鉆研,勇于創(chuàng)新才能,才能設計出滿意的程序。相關附錄#include #include#include#includeusing namespace std;#define NULL 0class student /定義類public: long num; char name20; int age; char sex20; char address30; float computer_score; float math_score; float English_score; student *next;int n;/定義主函數(shù)int main()student *creat(void); student *del(student*,long); student *insert(student *,student *); student *correct_num(student *,long); student *correct_nam(student *,string); student *search_num(student *,long); student *search_nam(student *,string); int save(student *head); void print(student*); student *head=NULL,*stu; long del_numb,correct_numb,search_numb; int choose,a; string search_name,correct_name; start:cout* 學 生 信 息 管 理 系 統(tǒng) * endl;/ goto指向的位置 cout* * endl; cout* 1.輸入學生信息 *endl; cout* 2.插入學生信息 *endl; cout* 3.修改學生信息 *endl; cout* 4.刪除學生信息 *endl; cout* 5.顯示學生信息 *endl; cout* 6.查詢學生信息 *endl; cout* 7.退出 *endl; cout 請輸入您的選擇(1-7):choose; switch(choose) /選擇結構,選擇要進行的操作 case 1: system(cls); /系統(tǒng)清屏 cout輸入學生信息:endl; head=creat();/調用函數(shù),建立鏈表 system(cls); goto start;/返回目錄 break; case 2: system(cls); coutendl輸入要插入的學生信息:; stu=new student; /新建結點 coutstu-num; coutstu-name; coutstu-age; coutstu-sex; coutstu-address; coutstu-computer_score; coutstu-math_score; coutstu-English_score; while(stu-num!=0) /結點學號不為空時插入 head=insert(head,stu);/調用函數(shù),插入結點 save(head);/將數(shù)據(jù)儲存在文件中 coutendl輸入要繼續(xù)插入的學生信息:; stu=new student; coutstu-num; /輸入結點相關信息 coutstu-name; coutstu-age; coutstu-sex; coutstu-address; coutstu-computer_score; coutstu-math_score; coutstu-English_score; system(cls); goto start; break; case 3: system(cls); coutendl輸入要修改信息學生的學號/姓endl; cout按學號查詢輸入1,姓名查詢輸入a;if(a=1) coutendlcorrect_numb ;head=correct_num(head,correct_numb); /按學號修改學生信息 save(head); if(a=2)coutendlcorrect_name; head=correct_nam(head,correct_name);/ 按姓名修改學生信息 save(head); system(cls); goto start; break; case 4: system(cls); coutendldel_numb; while(del_numb!=0) head=del(head,del_numb); save(head); coutdel_numb; system(cls); goto start; break; case 5: system(cls); cout學生信息如下:endl; system(cls); print(head); system(pause);/運行停在當前頁面 system(cls); goto start; break; case 6: system(cls); coutendl輸入要查詢信息學生的學號/姓名:endl; cout按學號查詢輸入1,姓名查詢輸入2:a; system(cls); if(a=1) coutendlsearch_numb; head=search_num(head,search_numb);/調用按學號查詢函數(shù) if(a=2)coutendlsearch_name; head=search_nam(head,search_name); /按姓名查詢學生信息 system(pause); system(cls); goto start; break; case 7: system(cls); cout按任意鍵退出程序!; exit(0);break;/調用系統(tǒng)函數(shù)exit,運行結束 default:coutendl請重新選擇1-7中的數(shù)字!;/輸入非選項數(shù)字時,返回主菜單 system(pause); system(cls); goto start; break; return 0; /創(chuàng)建鏈表的函數(shù) student *creat(void) ofstream outfile(f1.dat,ios:out);/打開文件 if(!outfile) cerr打開失敗endl; exit(0); student *head; student *p1,*p2; n=0; p1=p2=new student;/新建對象 coutp1-num; outfilenum ; /將數(shù)據(jù)存入文件 coutp1-name; outfilename ; coutp1-age; outfileage ; coutp1-sex; outfilesex ; coutp1-address; outfileaddress ; coutp1-computer_score; outfilecomputer_score ; coutp1-math_score; outfilemath_score ; coutp1-English_score; outfileEnglish_scorenum!=0) n=n+1; if(n=1) head=p1; else p2-next=p1;/p1指向下一個結點 p2=p1; p1=new student; coutp1-num; outfilenum ; coutp1-name; outfilename ; coutp1-age; outfileage ; coutp1-sex; outfilesex ; coutp1-address; outfileaddress ; coutp1-computer_score; outfilecomputer_score ; coutp1-math_score; outfilemath_score ; coutp1-English_score; outfileEnglish_scorenext=NULL; outfile.close();/關閉文件 return(head); /保存文件的函數(shù) int save(student *head) ofstream outfile(f1.dat,ios:out); if(!outfile) cerr打開文件出錯!endl; exit(0); student *p1=head,*p2; if(head=NULL) cout列表為空!endl;return 0; dooutfilenum name age sex address computer_score math_score English_score;/將鏈表數(shù)據(jù)存入文件 p2=p1;p1=p1-next; while(p2-next!=NULL); outfile.close(); return 0; /刪除數(shù)據(jù)的函數(shù) student *del(student *head,long num) student *p1,*p2; if(head=NULL) cout列表為空!num&p1-next!=NULL)/按學號從小到大查找 p2=p1;p1=p1-next; if(num=p1-num) if(p1=head)head=p1-next;/如果找到 else p2-next=p1-next; cout刪除的學號:numendl; n=n-1; else cout不能找到此學號的學生:next=NULL; else while(p0-nump1-num)&(p1-next!=NULL) p2=p1; p1=p1-next; if(p0-numnum) if(head=p1)head=p0;/p1學號最小,則作為頭指針 else p2-next=p0;/否則插入中間 p0-next=p1; else p1-next=p0;p0-next=NULL;/如果最大,則放在最后 n=n+1;/記錄結點數(shù) return(head); /按學號修改學生信息的函數(shù) student *correct_num(student *head,long num) student *p; if(head=NULL) cout列表為空!num&p-next!=NULL) p=p-next; if(num=p-num)/遭到后重新錄入學生的信息 coutp-num; coutp-name; coutp-age; coutp-sex; coutp-address; coutp-computer_score; coutp-math_score; coutp-English_score; else cout不能找到此學號的學生:num; return(head); /按姓名修改學生信息的函數(shù) student *correct_nam(student*head,string name) student *p; if(head=NULL) cout列表為空!name&p-next!=NULL) p=p-next; if(p-name=name) coutendl請重新輸入此學生的信息; coutp-num; coutp-name; coutp-age; coutp-sex; coutp-address; coutp-computer_score; coutp-math_score; coutp-English_score; else cout不能找到此學號的學生:name; return(head); /按學號查詢學生信息的函數(shù)student *search_num(student *head,long num) student *p; if(head=NULL) cout列表為空!num&p-next!=NULL) p=p-next; if(num=p-num) /找到后輸出學生信息 cout學生的學號:; coutnumendl; cout學生的姓名: ; coutnameendl; cout學生的年齡:; coutageendl; cout學生的性別: ; coutsexendl; cout學生的住址: ; coutaddressendl; cout學生的電腦成績: ; coutcomputer_scoreendl; cout學生的數(shù)學成績: ; coutmath_scoreendl; cout學生的英語成績: ; coutEnglish_scoreendl; else cout不能找到此學號的學生:num; return(head);/按姓名查詢學生信息的函數(shù) student *search_nam(student *head,string name) stud

溫馨提示

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

最新文檔

評論

0/150

提交評論