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

下載本文檔

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

文檔簡(jiǎn)介

學(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)操作的理解;將所學(xué)數(shù)據(jù)結(jié)構(gòu)方面的知識(shí)與一門具體的語(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ò)鍵盤輸入和文件輸入兩種(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) 存儲(chǔ)要求:通過(guò)鏈表存儲(chǔ)所有信息三、 算法的思想與算法實(shí)現(xiàn)步驟基本思想通過(guò)鏈表數(shù)據(jù)類型進(jìn)行基本操作,主要有三個(gè)模塊:分別是主函數(shù)模塊、主要操作函數(shù)及基本操作函數(shù)。其中,主函數(shù)負(fù)責(zé)其他子函數(shù)的調(diào)用實(shí)現(xiàn)以及基本界面的操作主要函數(shù)包括:voidStulnput(Student*);//學(xué)生成績(jī)管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用voidStuSelect(Student*);//學(xué)生成績(jī)管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用voidStuAlter(Student*); //學(xué)生成績(jī)管理系統(tǒng)的修改函數(shù),由主函數(shù)調(diào)用voidStuInsert(Student*); //學(xué)生成績(jī)管理系統(tǒng)的插入函數(shù),由主函數(shù)調(diào)用voidStuDelect(Student*); //學(xué)生成績(jī)管理系統(tǒng)的刪除函數(shù),由主函數(shù)調(diào)用voidStuSave(Student*); //學(xué)生成績(jī)管理系統(tǒng)的存儲(chǔ)函數(shù),由主函數(shù)調(diào)用基本操作函數(shù):voidStuOutput(Student*p); //輸出函數(shù)intStuImport(Student*head,Student*p); //輸入函數(shù)voidStuInputHand(Student*head); //學(xué)生成績(jī)管理系統(tǒng)的手動(dòng)輸入函數(shù), 由輸入函數(shù)調(diào)用voidStuInputFile(Student*head); //學(xué)生成績(jī)管理系統(tǒng)的文件輸入函數(shù), 由輸入函數(shù)調(diào)用voidStuSelectErg(Student*head); //學(xué)生成績(jī)管理系統(tǒng)的遍歷函數(shù),由查找函數(shù)調(diào)用voidStuSelectNumFind(Student*head); //學(xué)生成績(jī)管理系統(tǒng)的按學(xué)號(hào)查找函數(shù),由查找函數(shù)調(diào)用voidStuSelectSubFind(Student*head); //學(xué)生成績(jī)管理系統(tǒng)的按科目查找函數(shù), 由查找函數(shù)調(diào)用實(shí)現(xiàn)步驟首先,分析題目要求劃分實(shí)現(xiàn)模塊,定義基本數(shù)據(jù)類型,諸如結(jié)構(gòu)體、鏈表等;其次,針對(duì)上述的基本操作實(shí)現(xiàn)具體需要進(jìn)行的操作,具體實(shí)現(xiàn)每個(gè)環(huán)節(jié)需要進(jìn)行的基本操作,即具體編寫每個(gè)小函數(shù)實(shí)現(xiàn)功能;最后,編寫主函數(shù)對(duì)每個(gè)實(shí)現(xiàn)進(jìn)行按需調(diào)用,實(shí)現(xiàn)操作流程圖四.代碼:#include<stdio.h>#include<malloc.h>#include<string.h>structStudent{charname[10];charsubject[10];intnum;intgrade;Student*next;};voidStuMain(); //學(xué)生成績(jī)管理系統(tǒng)的主函數(shù),由 main函數(shù)調(diào)用

voidStulnput(Student*);voidStuSelect(Student*);voidStuAlter(Student*);voidStulnsert(Student*);voidStuDelect(Student*);voidStuSave(Student*);//學(xué)生成績(jī)管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用//學(xué)生成績(jī)管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用//學(xué)生成績(jī)管理系統(tǒng)的修改函數(shù),由主函數(shù)調(diào)用voidStulnput(Student*);voidStuSelect(Student*);voidStuAlter(Student*);voidStulnsert(Student*);voidStuDelect(Student*);voidStuSave(Student*);//學(xué)生成績(jī)管理系統(tǒng)的刪除函數(shù),由主函數(shù)調(diào)用voidStuOutput(Student*p);//輸出函數(shù)intStuImport(Student*head,Student*p); //輸入函數(shù)voidStuOutput(Student*p){//打印函數(shù),將鏈表的該節(jié)點(diǎn)信息輸出printf(”學(xué)生姓名:");voidStuOutput(Student*p);//輸出函數(shù)intStuImport(Student*head,Student*p); //輸入函數(shù)voidStuOutput(Student*p){//打印函數(shù),將鏈表的該節(jié)點(diǎn)信息輸出printf(”學(xué)生姓名:");printf("%s",p->name);printf(”學(xué)生號(hào)::");printf("%d",p->num);printf(”科目:");printf("%s",p->subject);printf(”學(xué)生成績(jī):");printf("%d\n“,p_>grade);}intStuImport(Student*head,Student*p){Student *Opinion=(Student輸入節(jié)點(diǎn)中學(xué)生號(hào)是否有重復(fù)Opinion=head->next;printf("學(xué)生姓名:\n”);scanf("%s",p->name);printf("學(xué)生號(hào):\n”);scanf("%d",&p->num);printf("科目:\n");scanf("%s",p_>subject);if(Opinion!=NULL){*)malloc(sizeof(Student));//用來(lái)判斷if(Opinion->num==p->num&&!strcmp(Opinion->subject,p->subject)){printf("該學(xué)生這門科目已有成績(jī),請(qǐng)重新輸入 \n");return1;}Opinion=Opinion->next;}printf("學(xué)生成績(jī):\n”);}voidmain(){StuMain();}voidStuMain(){voidStuMain(){chardecide='y';intnum=1;個(gè)子函數(shù)Student*head;head=(Student*)malloc(sizeof(Student));head->next=NULL;//定義while變量,函數(shù)是否繼續(xù)進(jìn)行II定義switch變量,函數(shù)跳轉(zhuǎn)到哪//定義鏈表的頭指針I(yè)I給頭指針開辟空間II初始化頭指針while(decide!='n'){printf(”***************************************************\n");printf(”********** i輸入2查找3修改4插入********\n");printf(”********** 5刪除6存儲(chǔ)7退出 ********\n");printf("***************************************************\n");scanf("%d",&num);switch(num){case1:Stulnput(head);break;case2:StuSelect(head);break;case3:StuAlter(head);break;case4:Stulnsert(head);break;case5:StuDelect(head);break;case6:StuSave(head);break;default:

decide='n:break;}};}voidStulnputHand(Student*head);數(shù)調(diào)用voidStuInputFile(Student*head);調(diào)用voidStuInput(Student*head){chardecide='y';intnum;子函數(shù)//學(xué)生成績(jī)管理系統(tǒng)的手動(dòng)輸入函數(shù),由輸入函//學(xué)生成績(jī)管理系統(tǒng)的文件輸入函數(shù),由輸入函數(shù)//學(xué)生成績(jī)管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用//定義while變量,函數(shù)是否繼續(xù)進(jìn)行////學(xué)生成績(jī)管理系統(tǒng)的手動(dòng)輸入函數(shù),由輸入函//學(xué)生成績(jī)管理系統(tǒng)的文件輸入函數(shù),由輸入函數(shù)//學(xué)生成績(jī)管理系統(tǒng)的輸入函數(shù),由主函數(shù)調(diào)用//定義while變量,函數(shù)是否繼續(xù)進(jìn)行//定義switch變量,函數(shù)跳轉(zhuǎn)到哪個(gè)printf(”printf(”***************************************************\n");1手動(dòng)輸入2文件輸入 3退出**\n");printf(”***************************************************\n");scanf("%d",&num);switch(num)case1:StuInputHand(head);break;case2:StulnputFile(head);default:decide='n';//學(xué)生成績(jī)管理系統(tǒng)的手動(dòng)輸入函數(shù),由輸入函*)malloc(sizeof(Student)); //學(xué)生成績(jī)管理系統(tǒng)的手動(dòng)輸入函數(shù),由輸入函*)malloc(sizeof(Student)); //鏈表中voidStulnputHand(Student *head)數(shù)調(diào)用{if(head->next==NULL){Student*point=(Student

最后一個(gè)節(jié)點(diǎn),只在該函數(shù)中存在point->next=NULL;intdecide=1;while(decide!=O){Student*p=(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/0\n");scanf("%d",&decide);}}elseprintf("管理系統(tǒng)中已存在信息,若想輸入學(xué)生信息,請(qǐng)轉(zhuǎn)插入子系統(tǒng) ");}voidStuInputFile(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");return;}FILE*fp;printf("請(qǐng)輸入文件名(包括物理地址) \n”);charfilename[10];scanf("%s",filename);if((fp=fopen(filename,"r"))==NULL){printf("cannotopenfile\n");return;}//用來(lái)//用來(lái)Student *Opinion=(Student *)malloc(sizeof(Student));

判斷輸入節(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->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");}//學(xué)生成績(jī)管理系統(tǒng)的遍歷函數(shù),由查找函數(shù)調(diào)//學(xué)生成績(jī)管理系統(tǒng)的遍歷函數(shù),由查找函數(shù)調(diào)//學(xué)生成績(jī)管理系統(tǒng)的按學(xué)號(hào)查找函數(shù),由//學(xué)生成績(jī)管理系統(tǒng)的按科目查找函數(shù), 由查用voidStuSelectNumFind(Student*head);查找函數(shù)調(diào)用voidStuSelectSubFind(Student*head);

找函數(shù)調(diào)用//學(xué)生成績(jī)管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用//學(xué)生成績(jī)管理系統(tǒng)的查找函數(shù),由主函數(shù)調(diào)用//定義while變量,函數(shù)是否繼續(xù)進(jìn)行//定義switch變量,函數(shù)跳轉(zhuǎn)到哪個(gè)chardecide='y:intnum;子函數(shù)while(decide!='n'){printf(”***************************************************\n");printf(”**** 1遍歷2學(xué)號(hào)查找 3科目查找4退出****\n");printf("***************************************************\n");scanf("%d",&num);switch(num){case1:StuSelectErg(head);break;case2:StuSelectNumFind(head);break;case3:StuSelectSubFind(head);break;default:decide='n:break;}}}voidStuSelectErg(Student*head) II學(xué)生成績(jī)管理系統(tǒng)的遍歷函數(shù), 由查找函數(shù)調(diào)用{Student*p=(Student*)malloc(sizeof(Student));p=head->next;inti=1;while(p!=NULL){printf("第%d位學(xué)生信息:\n",i);StuOutput(p);p=p->next;i++;}}voidStuSelectNumFind(Student *head)II學(xué)生成績(jī)管理系統(tǒng)的查找子系統(tǒng),有查找函數(shù)調(diào)用{intnum;printf(”輸入想要查找學(xué)生的學(xué)生號(hào): \n");scanf("%d",&num);Student*p=(Student*)malloc(sizeof(Student));p=head->next;inti=1;while(p!=NULL){if(num==p_>num){StuOutput(p);i++;}p=p->next;}if(i==1)printf("沒(méi)有該學(xué)生信息”);}由查voidStuSelectSubFind(Student*head) //學(xué)生成績(jī)管理系統(tǒng)的按科目查找函數(shù),由查找函數(shù)調(diào)用{charSub[10];printf("輸入想要查找科目:\n");scanf("%s",Sub);Student*p=(Student*)malloc(sizeof(Student));p=head->next;inti=1;while(p!=NULL){if(!strcmp(Sub,p->subject)){StuOutput(p);i++;}p=p->next;}if(i==1)printf("沒(méi)有該學(xué)生信息”);}voidStuAlter(Student*head) //學(xué)生成績(jī)管理系統(tǒng)的修改函數(shù),由主函數(shù)調(diào)用{intnum;

printf(”輸入想要查找學(xué)生的學(xué)生號(hào): \n");scanf("%d",&num);charSub[10];printf("輸入想要查找科目:\n");scanf("%s",Sub);Student*p=(Student*)malloc(sizeof(Student));p=head->next;inti=1;while(p!=NULL){if(num==p->num&&!strcmp(Sub,p->subject)){printf("輸入修改成績(jī):\n");scanf("%d",&p->grade);printf("修改成功\n”);i++;}p=p->next;if(i==1)printf("沒(méi)有該學(xué)生信息”);}}voidStuInsert(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->next; //找至U尾結(jié)點(diǎn)chardecide='y'; //定義while變量,函數(shù)是否繼續(xù)進(jìn)行intnum; //定義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){case1:StuImport(head,p);p->next=head->next;head->next=p;printf("插入成功\n”);break;case2:Stulmport(head,p);point->next=p;p->next=NULL;printf("插入成功\n”);break;default:decide='n:break;}}}voidStuDelect(Student*head) //學(xué)生成績(jī)管理系統(tǒng)的刪除函數(shù),由主函數(shù)調(diào)用{intnu

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 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ì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論