數(shù)據(jù)結(jié)構(gòu)之學(xué)生成績管理系統(tǒng)_第1頁
數(shù)據(jù)結(jié)構(gòu)之學(xué)生成績管理系統(tǒng)_第2頁
數(shù)據(jù)結(jié)構(gòu)之學(xué)生成績管理系統(tǒng)_第3頁
數(shù)據(jù)結(jié)構(gòu)之學(xué)生成績管理系統(tǒng)_第4頁
數(shù)據(jù)結(jié)構(gòu)之學(xué)生成績管理系統(tǒng)_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、學(xué)生成績管理系統(tǒng)一、實驗?zāi)康?.通過此次課程設(shè)計中學(xué)生成績管理系統(tǒng)的題目,掌握鏈表等數(shù)據(jù)結(jié)構(gòu)的基本操作方面的知識,并能靈活的解決一些基本的問題,加深對其性質(zhì)及各項操作的理解;2.將所學(xué)數(shù)據(jù)結(jié)構(gòu)方面的知識與一門具體的語言C語言來進(jìn)行實現(xiàn),感受數(shù)據(jù)結(jié)構(gòu)的強(qiáng)大作用,加深理解。二、試驗要求管理系統(tǒng)中有五個要求:輸入 查找 修改 插入 刪除 存儲(1) 輸入要求:能夠通過鍵盤輸入和文件輸入兩種(2) 查找要求:能夠根據(jù)學(xué)生號查找單個學(xué)生的信息,也可以遍歷所有學(xué)生信息(3) 修改要求:能夠根據(jù)學(xué)生號修改單個學(xué)生所有信息(4) 插入要求:能夠?qū)崿F(xiàn)頭插和尾插(5) 刪除要求:能夠根據(jù)學(xué)生號刪除單個學(xué)生信息(6

2、) 存儲要求:通過鏈表存儲所有信息三、 算法的思想與算法實現(xiàn)步驟1.基本思想通過鏈表數(shù)據(jù)類型進(jìn)行基本操作,主要有三個模塊:分別是主函數(shù)模塊、主要操作函數(shù)及基本操作函數(shù)。其中,主函數(shù)負(fù)責(zé)其他子函數(shù)的調(diào)用實現(xiàn)以及基本界面的操作主要函數(shù)包括:void StuInput(Student *); /學(xué)生成績管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用void StuSelect(Student *); /學(xué)生成績管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用void StuAlter(Student *); /學(xué)生成績管理系統(tǒng)的修改函數(shù),由主函數(shù)調(diào)用void StuInsert(Student *); /學(xué)生成績管理系統(tǒng)的插入函

3、數(shù),由主函數(shù)調(diào)用void StuDelect(Student *); /學(xué)生成績管理系統(tǒng)的刪除函數(shù),由主函數(shù)調(diào)用void StuSave(Student *); /學(xué)生成績管理系統(tǒng)的存儲函數(shù),由主函數(shù)調(diào)用基本操作函數(shù):void StuOutput(Student *p); /輸出函數(shù)int StuImport(Student *head,Student *p); /輸入函數(shù)void StuInputHand(Student *head); /學(xué)生成績管理系統(tǒng)的手動輸入函數(shù),由輸入函數(shù)調(diào)用void StuInputFile(Student *head); /學(xué)生成績管理系統(tǒng)的文件輸入函數(shù),由輸入

4、函數(shù)調(diào)用void StuSelectErg(Student *head); /學(xué)生成績管理系統(tǒng)的遍歷函數(shù),由查找函數(shù)調(diào)用 void StuSelectNumFind(Student *head); /學(xué)生成績管理系統(tǒng)的按學(xué)號查找函數(shù),由查找函數(shù)調(diào)用void StuSelectSubFind(Student *head); /學(xué)生成績管理系統(tǒng)的按科目查找函數(shù),由查找函數(shù)調(diào)用2.實現(xiàn)步驟首先,分析題目要求劃分實現(xiàn)模塊,定義基本數(shù)據(jù)類型,諸如結(jié)構(gòu)體、鏈表等;其次,針對上述的基本操作實現(xiàn)具體需要進(jìn)行的操作,具體實現(xiàn)每個環(huán)節(jié)需要進(jìn)行的基本操作,即具體編寫每個小函數(shù)實現(xiàn)功能;最后,編寫主函數(shù)對每個實現(xiàn)進(jìn)行

5、按需調(diào)用,實現(xiàn)操作。3.流程圖mainStuMainStuInputStuSelectStuAlterStuInsertStuDelectStuSaveStuInputHandStuInputFileStuSelectErgStuSelectNumFindStuSelectSubFind四代碼:#include#include#includestruct Student char name10; char subject10; int num; int grade; Student *next;void StuMain(); /學(xué)生成績管理系統(tǒng)的主函數(shù),由main函數(shù)調(diào)用void StuInp

6、ut(Student *); /學(xué)生成績管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用void StuSelect(Student *); /學(xué)生成績管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用void StuAlter(Student *); /學(xué)生成績管理系統(tǒng)的修改函數(shù),由主函數(shù)調(diào)用void StuInsert(Student *); /學(xué)生成績管理系統(tǒng)的插入函數(shù),由主函數(shù)調(diào)用void StuDelect(Student *); /學(xué)生成績管理系統(tǒng)的刪除函數(shù),由主函數(shù)調(diào)用void StuSave(Student *); /學(xué)生成績管理系統(tǒng)的存儲函數(shù),由主函數(shù)調(diào)用void StuOutput(Student *p);

7、 /輸出函數(shù)int StuImport(Student *head,Student *p); /輸入函數(shù)void StuOutput(Student *p) /打印函數(shù),將鏈表的該節(jié)點信息輸出 printf(學(xué)生姓名:); printf(%s ,p-name);printf(學(xué)生號:);printf(%d ,p-num);printf(科目: );printf(%s ,p-subject);printf(學(xué)生成績:);printf(%d n,p-grade);int StuImport(Student *head,Student *p)Student *Opinion=(Student *)m

8、alloc(sizeof(Student); /用來判斷輸入節(jié)點中學(xué)生號是否有重復(fù)Opinion=head-next; printf(學(xué)生姓名:n); scanf(%s,p-name);printf(學(xué)生號:n);scanf(%d,&p-num);printf(科目:n);scanf(%s,p-subject);if(Opinion!=NULL) if(Opinion-num=p-num&!strcmp(Opinion-subject,p-subject) printf(該學(xué)生這門科目已有成績,請重新輸入n);return 1; Opinion=Opinion-next;printf(學(xué)生成績

9、:n);scanf(%d,&p-grade);return 0;void main() StuMain();void StuMain() char decide=y; /定義while變量,函數(shù)是否繼續(xù)進(jìn)行int num=1; /定義switch變量,函數(shù)跳轉(zhuǎn)到哪個子函數(shù)Student *head; /定義鏈表的頭指針head=(Student *)malloc(sizeof(Student); /給頭指針開辟空間head-next=NULL; /初始化頭指針 while(decide!=n) printf( *n); printf( * 1 輸入 2 查找 3 修改 4 插入 *n);pri

10、ntf( * 5 刪除 6 存儲 7 退出 *n); printf( *n); scanf(%d,&num);switch(num) case 1: StuInput(head); break; case 2: StuSelect(head); break; case 3: StuAlter(head); break; case 4: StuInsert(head); break; case 5: StuDelect(head); break; case 6: StuSave(head); break; default: decide=n; break;void StuInputHand(St

11、udent *head); /學(xué)生成績管理系統(tǒng)的手動輸入函數(shù),由輸入函數(shù)調(diào)用void StuInputFile(Student *head); /學(xué)生成績管理系統(tǒng)的文件輸入函數(shù),由輸入函數(shù)調(diào)用void StuInput(Student *head) /學(xué)生成績管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用 char decide=y; /定義while變量,函數(shù)是否繼續(xù)進(jìn)行int num; /定義switch變量,函數(shù)跳轉(zhuǎn)到哪個子函數(shù)while(decide!=n) printf( *n); printf( * 1 手動輸入 2 文件輸入 3 退出 *n); printf( *n);scanf(%d,&nu

12、m);switch(num)case 1:StuInputHand(head);break;case 2:StuInputFile(head);default:decide=n;break;void StuInputHand(Student *head) /學(xué)生成績管理系統(tǒng)的手動輸入函數(shù),由輸入函數(shù)調(diào)用 if(head-next=NULL) Student *point=(Student *)malloc(sizeof(Student); /鏈表中最后一個節(jié)點,只在該函數(shù)中存在 point-next=NULL; int decide=1; while(decide!=0) Student *p

13、=(Student *)malloc(sizeof(Student); p-next=NULL; StuImport(head,p); if(head-next=NULL) head-next=p; point=p; else point-next=p; point=p; printf(是否繼續(xù):1/0n); scanf(%d,&decide); else printf(管理系統(tǒng)中已存在信息,若想輸入學(xué)生信息,請轉(zhuǎn)插入子系統(tǒng));void StuInputFile(Student *head) /學(xué)生成績管理系統(tǒng)的文件輸入函數(shù),由輸入函數(shù)調(diào)用 if(head-next!=NULL) printf

14、(學(xué)生管理系統(tǒng)中已有信息,請?zhí)D(zhuǎn)到插入選項n); return ; FILE *fp; printf(請輸入文件名(包括物理地址)n); char filename10;scanf(%s,filename); if(fp=fopen(filename,r)=NULL) printf(can not open filen); return; Student *point=(Student *)malloc(sizeof(Student);Student *Opinion=(Student *)malloc(sizeof(Student); /用來判斷輸入節(jié)點中學(xué)生號是否有重復(fù) while(!fe

15、of(fp) Opinion=head-next; Student *p=(Student *)malloc(sizeof(Student); p-next=NULL; fread(p,sizeof(Student),1,fp); if(Opinion!=NULL) if(Opinion-num=p-num&!strcmp(Opinion-subject,p-subject) printf(該文件中有重復(fù)學(xué)生信息,請驗明再傳輸n); head-next=NULL;return ; Opinion=Opinion-next; if(head-next=NULL) head-next=p; poi

16、nt=p; else point-next=p; point=p; ; Opinion=head-next; while(Opinion-next!=NULL) Opinion=Opinion-next; if(Opinion-next-next=NULL) Opinion-next=NULL; ; fclose(fp); printf(傳輸成功n);void StuSelectErg(Student *head); /學(xué)生成績管理系統(tǒng)的遍歷函數(shù),由查找函數(shù)調(diào)用 void StuSelectNumFind(Student *head); /學(xué)生成績管理系統(tǒng)的按學(xué)號查找函數(shù),由查找函數(shù)調(diào)用voi

17、d StuSelectSubFind(Student *head); /學(xué)生成績管理系統(tǒng)的按科目查找函數(shù),由查找函數(shù)調(diào)用void StuSelect(Student *head) /學(xué)生成績管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用 char decide=y; /定義while變量,函數(shù)是否繼續(xù)進(jìn)行int num; /定義switch變量,函數(shù)跳轉(zhuǎn)到哪個子函數(shù)while(decide!=n) printf( *n); printf( * 1 遍歷 2 學(xué)號查找 3 科目查找 4 退出 *n); printf( *n);scanf(%d,&num);switch(num)case 1:StuSelect

18、Erg(head);break;case 2:StuSelectNumFind(head);break;case 3: StuSelectSubFind(head);break;default:decide=n;break;void StuSelectErg(Student *head) /學(xué)生成績管理系統(tǒng)的遍歷函數(shù),由查找函數(shù)調(diào)用 Student *p=(Student *)malloc(sizeof(Student);p=head-next;int i=1;while(p!=NULL) printf(第%d位學(xué)生信息:n,i); StuOutput(p); p=p-next; i+;voi

19、d StuSelectNumFind(Student *head) /學(xué)生成績管理系統(tǒng)的查找子系統(tǒng),有查找函數(shù)調(diào)用 int num; printf(輸入想要查找學(xué)生的學(xué)生號:n); scanf(%d,&num); Student *p=(Student *)malloc(sizeof(Student);p=head-next;int i=1;while(p!=NULL) if(num=p-num) StuOutput(p); i+; p=p-next; if(i=1) printf(沒有該學(xué)生信息);void StuSelectSubFind(Student *head) /學(xué)生成績管理系統(tǒng)的

20、按科目查找函數(shù),由查找函數(shù)調(diào)用 char Sub10; printf(輸入想要查找科目:n); scanf(%s,Sub); Student *p=(Student *)malloc(sizeof(Student);p=head-next;int i=1;while(p!=NULL) if(!strcmp(Sub,p-subject) StuOutput(p); i+; p=p-next; if(i=1)printf(沒有該學(xué)生信息);void StuAlter(Student *head) /學(xué)生成績管理系統(tǒng)的修改函數(shù),由主函數(shù)調(diào)用 int num; printf(輸入想要查找學(xué)生的學(xué)生號:

21、n); scanf(%d,&num);char Sub10; printf(輸入想要查找科目:n); scanf(%s,Sub); Student *p=(Student *)malloc(sizeof(Student);p=head-next;int i=1;while(p!=NULL) if(num=p-num&!strcmp(Sub,p-subject) printf(輸入修改成績:n); scanf(%d,&p-grade); printf(修改成功n); i+; p=p-next; if(i=1) printf(沒有該學(xué)生信息);void StuInsert(Student *hea

22、d) /學(xué)生成績管理系統(tǒng)的插入函數(shù),由主函數(shù)調(diào)用 Student *point=(Student *)malloc(sizeof(Student); point=head-next; while(point-next!=NULL) point=point-next; /找到尾結(jié)點 char decide=y; /定義while變量,函數(shù)是否繼續(xù)進(jìn)行 int num; /定義switch變量,函數(shù)跳轉(zhuǎn)到哪個子函數(shù) while(decide!=n) printf( *n); printf( * 1 頭插 2 尾插 3 退出 *n); printf( *n); scanf(%d,&num); Stu

23、dent *p=(Student *)malloc(sizeof(Student); switch(num) case 1: StuImport(head,p); p-next=head-next; head-next=p; printf(插入成功n); break; case 2: StuImport(head,p); point-next=p; p-next=NULL; printf(插入成功n); break; default: decide=n; break; void StuDelect(Student *head) /學(xué)生成績管理系統(tǒng)的刪除函數(shù),由主函數(shù)調(diào)用 int num; printf(輸入想要刪除學(xué)生

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論