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

下載本文檔

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

文檔簡(jiǎn)介

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

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

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

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

5、按需調(diào)用,實(shí)現(xiàn)操作。3.流程圖mainStuMainStuInputStuSelectStuAlterStuInsertStuDelectStuSaveStuInputHandStuInputFileStuSelectErgStuSelectNumFindStuSelectSubFind四代碼:#include<stdio.h>#include<malloc.h>#include<string.h>struct Student char name10; char subject10; int num; int grade; Student *next;voi

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

7、學(xué)生成績(jī)管理系統(tǒng)的存儲(chǔ)函數(shù),由主函數(shù)調(diào)用void StuOutput(Student *p); /輸出函數(shù)int StuImport(Student *head,Student *p); /輸入函數(shù)void StuOutput(Student *p) /打印函數(shù),將鏈表的該節(jié)點(diǎn)信息輸出 printf("學(xué)生姓名:"); printf("%s ",p->name);printf("學(xué)生號(hào):");printf("%d ",p->num);printf("科目: ");printf(&qu

8、ot;%s ",p->subject);printf("學(xué)生成績(jī):");printf("%d n",p->grade);int StuImport(Student *head,Student *p)Student *Opinion=(Student *)malloc(sizeof(Student); /用來(lái)判斷輸入節(jié)點(diǎn)中學(xué)生號(hào)是否有重復(fù)Opinion=head->next; printf("學(xué)生姓名:n"); scanf("%s",p->name);printf("學(xué)生號(hào)

9、: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é)生這門(mén)科目已有成績(jī),請(qǐng)重新輸入n");return 1; Opinion=Opinion->next;printf("學(xué)生成績(jī):n

10、");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)到哪個(gè)子函數(shù)Student *head; /定義鏈表的頭指針head=(Student *)malloc(sizeof(Student); /給頭指針開(kāi)辟空間head->next=NULL; /初始化頭指針 while(decide!='n') pri

11、ntf(" *n"); printf(" * 1 輸入 2 查找 3 修改 4 插入 *n");printf(" * 5 刪除 6 存儲(chǔ) 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); bre

12、ak; case 5: StuDelect(head); break; case 6: StuSave(head); break; default: decide='n' break;void StuInputHand(Student *head); /學(xué)生成績(jī)管理系統(tǒng)的手動(dòng)輸入函數(shù),由輸入函數(shù)調(diào)用void StuInputFile(Student *head); /學(xué)生成績(jī)管理系統(tǒng)的文件輸入函數(shù),由輸入函數(shù)調(diào)用void StuInput(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用 char decide='y' /定義while變

13、量,函數(shù)是否繼續(xù)進(jìn)行int num; /定義switch變量,函數(shù)跳轉(zhuǎn)到哪個(gè)子函數(shù)while(decide!='n') printf(" *n"); printf(" * 1 手動(dòng)輸入 2 文件輸入 3 退出 *n"); printf(" *n");scanf("%d",&num);switch(num)case 1:StuInputHand(head);break;case 2:StuInputFile(head);default:decide='n'break;void

14、StuInputHand(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的手動(dòng)輸入函數(shù),由輸入函數(shù)調(diào)用 if(head->next=NULL) Student *point=(Student *)malloc(sizeof(Student); /鏈表中最后一個(gè)節(jié)點(diǎn),只在該函數(shù)中存在 point->next=NULL; int decide=1; while(decide!=0) Student *p=(Student *)malloc(sizeof(Student); p->next=NULL; StuImport(head,p); if(head->next=NUL

15、L) head->next=p; point=p; else point->next=p; point=p; printf("是否繼續(xù):1/0n"); scanf("%d",&decide); else printf("管理系統(tǒng)中已存在信息,若想輸入學(xué)生信息,請(qǐng)轉(zhuǎn)插入子系統(tǒng)");void StuInputFile(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的文件輸入函數(shù),由輸入函數(shù)調(diào)用 if(head->next!=NULL) printf("學(xué)生管理系統(tǒng)中已有信息,請(qǐng)?zhí)D(zhuǎn)到插入選項(xiàng)n&quo

16、t;); return ; FILE *fp; printf("請(qǐng)輸入文件名(包括物理地址)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);

17、/用來(lái)判斷輸入節(jié)點(diǎn)中學(xué)生號(hào)是否有重復(fù) while(!feof(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é)生信息,請(qǐng)驗(yàn)明再傳輸n"); head->

18、;next=NULL;return ; Opinion=Opinion->next; if(head->next=NULL) head->next=p; point=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&q

19、uot;);void StuSelectErg(Student *head); /學(xué)生成績(jī)管理系統(tǒng)的遍歷函數(shù),由查找函數(shù)調(diào)用 void StuSelectNumFind(Student *head); /學(xué)生成績(jī)管理系統(tǒng)的按學(xué)號(hào)查找函數(shù),由查找函數(shù)調(diào)用void StuSelectSubFind(Student *head); /學(xué)生成績(jī)管理系統(tǒng)的按科目查找函數(shù),由查找函數(shù)調(diào)用void StuSelect(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用 char decide='y' /定義while變量,函數(shù)是否繼續(xù)進(jìn)行int num; /定義swit

20、ch變量,函數(shù)跳轉(zhuǎn)到哪個(gè)子函數(shù)while(decide!='n') printf(" *n"); printf(" * 1 遍歷 2 學(xué)號(hào)查找 3 科目查找 4 退出 *n"); printf(" *n");scanf("%d",&num);switch(num)case 1:StuSelectErg(head);break;case 2:StuSelectNumFind(head);break;case 3: StuSelectSubFind(head);break;default:dec

21、ide='n'break;void StuSelectErg(Student *head) /學(xué)生成績(jī)管理系統(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+;void StuSelectNumFind(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的查找子系統(tǒng),有查找函數(shù)調(diào)用 int num; prin

22、tf("輸入想要查找學(xué)生的學(xué)生號(hào):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("沒(méi)有該學(xué)生信息");void StuSelectSubFind(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的按科目查找函數(shù),由查找函數(shù)調(diào)用 cha

23、r 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("沒(méi)有該學(xué)生信息");void StuAlter(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的修改函數(shù),由主函數(shù)調(diào)用

24、int num; printf("輸入想要查找學(xué)生的學(xué)生號(hào):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("輸入修

25、改成績(jī):n"); scanf("%d",&p->grade); printf("修改成功n"); i+; p=p->next; if(i=1) printf("沒(méi)有該學(xué)生信息");void StuInsert(Student *head) /學(xué)生成績(jī)管理系統(tǒng)的插入函數(shù),由主函數(shù)調(diào)用 Student *point=(Student *)malloc(sizeof(Student); point=head->next; while(point->next!=NULL) point=point-&g

26、t;next; /找到尾結(jié)點(diǎn) char decide='y' /定義while變量,函數(shù)是否繼續(xù)進(jìn)行 int num; /定義switch變量,函數(shù)跳轉(zhuǎn)到哪個(gè)子函數(shù) while(decide!='n') printf(" *n"); printf(" * 1 頭插 2 尾插 3 退出 *n"); printf(" *n"); scanf("%d",&num); Student *p=(Student *)malloc(sizeof(Student); switch(num)

27、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é)生成績(jī)管理系統(tǒng)的刪除函數(shù),由主函數(shù)調(diào)用 int num; printf("輸入想要?jiǎng)h除學(xué)生的學(xué)生號(hào):n"); scanf("%d",&num);char Sub10; printf("輸入想要?jiǎng)h除科目:n"); scanf("%s",Sub

溫馨提示

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

評(píng)論

0/150

提交評(píng)論