


版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、C語(yǔ)言課程設(shè)計(jì)學(xué)生信息管理系統(tǒng)姓名洪偉生院系計(jì)算機(jī)學(xué)院日期2015年7月5日目錄第一章設(shè)計(jì)要求第二章算法分析1. 理論依據(jù)主要實(shí)現(xiàn)方法2.1整體流程圖2.2函數(shù)功能和函數(shù)之間的調(diào)用關(guān)系第三章代碼(源代碼)第四章分析說(shuō)明第五章總結(jié)第一章、設(shè)計(jì)要求1、利用所學(xué)的知識(shí)、理論和實(shí)際結(jié)合,利用資源,采用模塊化的結(jié)構(gòu),使用模仿修改自主設(shè)計(jì)相結(jié)合的方法,鍛煉學(xué)生綜合分析解決實(shí)際問(wèn)題的編程能力;2、通過(guò)C語(yǔ)言各個(gè)函數(shù)功能來(lái)實(shí)現(xiàn)對(duì)學(xué)生信息的管理,學(xué)生信息包括學(xué)生,學(xué)號(hào),各科成績(jī);管理方式包括對(duì)學(xué)生信息的錄入,保存,排序,查找、修改、刪除等功能。第二章、算法分析1、程序理論依據(jù)通過(guò)C語(yǔ)言的程序設(shè)計(jì)基礎(chǔ)的掌握,對(duì)學(xué)
2、生成績(jī)管理系統(tǒng)進(jìn)行編寫程序。首先,通過(guò)鏈表這一數(shù)據(jù)結(jié)構(gòu)來(lái)對(duì)學(xué)生的信息進(jìn)行錄入以及操作,在其過(guò)程中,通過(guò)各個(gè)功能語(yǔ)句以及選擇結(jié)構(gòu),循環(huán)結(jié)構(gòu)等方式的結(jié)合來(lái)達(dá)到所要實(shí)現(xiàn)的程序功能。最后通過(guò)對(duì)C語(yǔ)言中對(duì)文件的操作,對(duì)已有學(xué)生成績(jī)的讀取和新建學(xué)生成績(jī)的錄入保存。2、主要實(shí)現(xiàn)方法2.1整體流程圖學(xué)生信息管退出返回主菜單理系統(tǒng)進(jìn)入學(xué)學(xué)學(xué)學(xué)學(xué)學(xué)生生生生生生信信信信信信息息息息息息錄瀏查修增刪入覽找改加除2.2、函數(shù)功能和函數(shù)之間的調(diào)用關(guān)系2.2.1、函數(shù)功能:voidMenu_1();/主菜單二級(jí)菜單voidMenu_2();/voidswap(structstudent*phead,structstuden
3、t*pback);表節(jié)點(diǎn)互換/鏈voidSave(structstudent*head);/盤寫入磁voidSearch(structstudent*head);/生信息查找學(xué)voidRead(structstudent*head);/生信息顯示學(xué)voidSort(structstudent*head);/點(diǎn)排序鏈表節(jié)structstudent*Create();/錄入學(xué)生信息手動(dòng)structstudent*Readpoint();/磁盤文件寫入structstudent*Modify(structstudent*head);/體成員修改鏈表結(jié)構(gòu)structstudent*Add(struct
4、student*head);/點(diǎn)插入鏈表節(jié)structstudent*Delete(structstudent*head);/鏈表節(jié)點(diǎn)刪除2.2.2、函數(shù)之間的調(diào)用關(guān)系:通過(guò)switch語(yǔ)句進(jìn)行指令選擇:case1:學(xué)生信息錄入調(diào)用函數(shù)Create()、Save()、Menu_1()、Menu_2()case2:學(xué)生信息瀏覽調(diào)用函數(shù)Readpoint()、Sort()、Read()、Save()、Menu_1()、Menu_2()case3:學(xué)生信息查找調(diào)用函數(shù)Search()、Readpoint()、Menu_1()、Menu_2()case4:學(xué)生信息修改調(diào)用函數(shù)Modify()、Read
5、point()、Save()、Menu_1()、Menu_2()case5:學(xué)生信息增加調(diào)用函數(shù)Add()、Readpoint()、Save()、Menu_1()、Menu_2()case6:學(xué)生信息刪除調(diào)用函數(shù)Delete()、Readpoint()Save()、Menu_1()、Menu_2()case0:返回主菜單調(diào)用函數(shù)Menu_1()第三章、代碼(源代碼)/*學(xué)生信息管理系統(tǒng)*/#include<stdio.h>#include<stdlib.h>#include<string.h>structstudent/定義結(jié)構(gòu)體intnum;charnam
6、e24;charsex5;intChinese;intMath;intEnglish;structstudent*next;voidswap(structstudent*phead,structstudent*pback);/鏈表節(jié)點(diǎn)互換voidSave(structstudent*head);/寫入磁盤voidSearch(structstudent*head);/查找學(xué)生信息voidRead(structstudent*head);/顯示學(xué)生信息voidSort(structstudent*head);/鏈表節(jié)點(diǎn)排序structstudent*Readpoint();/磁盤文件寫入存str
7、uctstudent*Create();/學(xué)生信息手動(dòng)錄入structstudent*Modify(structstudent*head);/鏈表結(jié)構(gòu)體成員修改structstudent*Add(structstudent*head);/鏈表節(jié)點(diǎn)插入structstudent*Delete(structstudent*head);/鏈表主菜單二級(jí)菜單節(jié)點(diǎn)刪除;voidMenu_1();/voidMenu_2();/intmain(void)(Menu_1();return0;voidMenu_1()(intnum;printf("tttt學(xué)生信息管理系統(tǒng)ttttn");pr
8、intf("ttt1:進(jìn)入學(xué)生信息管理n");/主菜單printf("ttt0:退出學(xué)生信息管理n");printf("請(qǐng)您輸入指令:");scanf("%d”,&num);switch(num)(case1:Menu_2();break;您已退出default:printf("學(xué)生信息管理系統(tǒng)n");break;/*/voidMenu_2()structstudent*head;intnum;printf("ttt歡迎進(jìn)入n");printf("n");p
9、rintf("ttt1:學(xué)生信息錄入n");printf(-ttt2:學(xué)生信息瀏覽n");printf("ttt3:學(xué)生信息查找n");printf("ttt4:學(xué)生信息修改n");/二級(jí)菜單printf("ttt5:學(xué)生信息增加n");printf(-ttt6:學(xué)生信息刪除n");printf("ttt0:返回主菜單n");printf("n");printf("請(qǐng)您輸入指令:");scanf("%d",&
10、num);switch(num)case1:head=Create();Save(head);printf("n");printf("ttt1:返回主菜單n");/手動(dòng)錄入學(xué)生數(shù)據(jù)printf("ttt2:返回二級(jí)菜單n");printf("n");printf("請(qǐng)您輸入指令:");scanf("%d",&num);switch(num)case1:Menu_1();break;case2:Menu_2();break;default:(printf(-輸入無(wú)效,返
11、回二級(jí)菜單!n");Menu_2();break;break;case2:(head=Readpoint();/寫入鏈表,返回頭指針Sort(head);printf(-ttt以學(xué)號(hào)升序排列n");Read(head);/鏈表數(shù)據(jù)寫入文件Save(head);printf("n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級(jí)菜單n");printf("n");printf("請(qǐng)您輸入指令:");scanf("%d",&a
12、mp;num);switch(num)(case1:Menu_1();break;case2:Menu_2();break;default:(printf(-輸入無(wú)效,返回二級(jí)菜單!n");Menu_2();break;break;case3:(head=Readpoint();Search(head);/查找學(xué)生信息printf("n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級(jí)菜單n");printf("n");printf("請(qǐng)您輸入指令:"
13、);scanf("%d",&num);switch(num)case1:Menu_1();break;case2:Menu_2();break;default:printf(-輸入無(wú)效,返回二級(jí)菜單!n");Menu_2();break;break;case4:head=Readpoint();Modify(head);/修改結(jié)構(gòu)體成員并保存到文件Save(head);printf("n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級(jí)菜單n");printf(&
14、quot;n");printf("請(qǐng)您輸入指令:");scanf("%d",&num);switch(num)case1:Menu_1();break;case2:Menu_2();break;default:printf(-輸入無(wú)效,返回二級(jí)菜單!n");Menu_2();break;break;case5:(head=Readpoint();增加學(xué)生信Add(head);息并保存到文件Save(head);printf("n");printf("ttt1:返回主菜單n");print
15、f("ttt2:返回二級(jí)菜單n");printf("n");printf("請(qǐng)您輸入指令:");scanf("%d”,&num);switch(num)(case1:Menu_1();break;case2:Menu_2();break;default:(printf("輸入無(wú)效,返回二級(jí)菜單!n");Menu_2();break;break;case6:(head=Readpoint();head=Delete(head);/刪除學(xué)生信息并保存到文件Save(head);printf("
16、;n");printf("ttt1:返回主菜單n");printf("ttt2:返回二級(jí)菜單n");printf("n");printf("請(qǐng)您輸入指令:");scanf("%d",&num);switch(num)(case1:Menu_1();break;case2:Menu_2();break;default:(printf(-輸入無(wú)效,返回二級(jí)菜單!n");Menu_2();break;break;case0:Menu_1();break;default:(p
17、rintf("請(qǐng)重新輸入n");Menu_2();break;/*-*/structstudent*Create()/學(xué)生信息手動(dòng)錄入(structstudent*head,*p,*q;intn;p=q=(structstudent*)malloc(sizeof(structstudent);printf(-請(qǐng)輸入學(xué)生的、學(xué)號(hào)、性別、語(yǔ)文成績(jī)、高等數(shù)學(xué)成績(jī)、英語(yǔ)成績(jī):n");scanf("%s",q->name);scanf("%d%s%d%d%d",&q->num,&q->sex,&
18、;q->Chinese,&q->Math,&q->English);n=0;head=NULL;while(q->num!=0)(n=n+1;if(n=1)head=q;elsep->next=q;p=q;q=(structstudent*)malloc(sizeof(structstudent);scanf("%s",q->name);scanf("%d%s%d%d%d",&q->num,q->sex,&q->Chinese,&q->Math,&
19、q->English);p->next=NULL;printf(-學(xué)生信息錄入成功!n");returnhead;/*-*/structstudent*Readpoint()/學(xué)生信息寫入存,便于操作FILE*fp1;structstudent*head,*p,*q;intn;if(fp1=fopen("E:test.txt","rb")=NULL)printf("openfileerror!n");exit(0);p=q=(structstudent*)malloc(sizeof(structstudent);
20、fscanf(fp1,"%s%d%s%d%d%d",q->name,&q->num,q->sex,&q->Chinese,&q->Math,&q->English);n=0;head=NULL;while(!feof(fp1)n=n+1;if(n=1)head=q;elsep->next=q;p=q;q=(structstudent*)malloc(sizeof(structstudent);fscanf(fp1,"%s%d%s%d%d%d",&q->name,&am
21、p;q->num,&q->sex,&q->Chinese,&q->Math,&q->English);p->next=NULL;fclose(fp1);returnhead;/*-*/voidSwap(structstudent*phead,structstudent*pback)/鏈表元素?cái)?shù)據(jù)交換structstudent*temp=(structstudent*)malloc(sizeof(structstudent);strcpy(temp->name,phead->name);temp->num=ph
22、ead->num;strcpy(temp->sex,phead->sex);temp->Chinese=phead->Chinese;temp->Math=phead->Math;temp->English=phead->English;strcpy(phead->name,pback->name);phead->num=pback->num;strcpy(phead->sex,pback->sex);phead->Chinese=pback->Chinese;phead->Math=p
23、back->Math;phead->English=pback->English;strcpy(pback->name,temp->name);pback->num=temp->num;strcpy(pback->sex,temp->sex);pback->Chinese=temp->Chinese;pback->Math=temp->Math;pback->English=temp->English;free(temp);/*-*/voidSort(structstudent*head)/學(xué)號(hào)排序(st
24、ructstudent*phead=(structstudent*)malloc(sizeof(structstudent);structstudent*pback=(structstudent*)malloc(sizeof(structstudent);phead=head;while(phead)(intNum=phead->num;pback=phead->next;while(pback)(if(Num>pback->num)(Swap(phead,pback);Num=phead->num;pback=pback->next;phead=phead
25、->next;/*-*/voidRead(structstudent*head)/學(xué)生信息讀取(structstudent*p;p=head;printf("n");printf(-學(xué)生的、學(xué)號(hào)、性別、語(yǔ)文成績(jī)、高等數(shù)學(xué)成績(jī)、英語(yǔ)成績(jī):n");while(p!=NULL)(printf("%st%dt%st%dt%dtt%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);p=p->next;printf("n");
26、/*-*/voidSave(structstudent*head)/學(xué)生信息保存到文件structstudent*p;FILE*fp;if(fp=fopen("E:test.txt","wb")=NULL)printf("openfileerror!n");exit(0);p=head;while(p!=NULL)fprintf(fp,"%s%d%s%d%d%d",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);fprin
27、tf(fp,"%s","rn");p=p->next;fclose(fp);/*-*/voidSearch(structstudent*head)/學(xué)生信息查找intn;structstudent*p;charname24;intnum;charsex5;intChinese;intMath;intEnglish;printf("您想以何種方式進(jìn)行查找:n");printf("1;n");printf("2:學(xué)號(hào)n");printf("3:性另叭n");printf(&
28、quot;4:語(yǔ)文成績(jī)n");printf("5:數(shù)學(xué)成績(jī)n");printf("6:英語(yǔ)成績(jī)n");printf("0:返回二級(jí)菜單n");scanf("%d",&n);switch(n)case1:printf(-請(qǐng)輸入:");/按查找scanf("%s",name);p=head;while(strcmp(name,p->name)!=0&&p->next!=NULL)p=p->next;if(strcmp(name,p->
29、;name)=0)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);elseprintf("查無(wú)此人!n");break;case2:printf(-請(qǐng)輸入學(xué)號(hào):");/按學(xué)號(hào)查找scanf("%d",&num);p=head;while(num!=p->num&&p->next!=NULL)p=p->next;if(num=p->num)p
30、rintf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);elseprintf("查無(wú)此人!n");break;case3:(printf(-請(qǐng)輸入性別:");/按性別查找scanf("%s",sex);p=head;while(p!=NULL)(if(strcmp(sex,p->sex)=0)printf("%s%d%s%d%d%dn",p->name,p->
31、num,p->sex,p->Chinese,p->Math,p->English);p=p->next;break;case4:(printf("請(qǐng)輸入語(yǔ)文成績(jī):");/按語(yǔ)文成績(jī)查找scanf("%d",&Chinese);p=head;while(p!=NULL)(if(Chinese=p->Chinese)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->Englis
32、h);p=p->next;break;case5:(printf("請(qǐng)輸入高等數(shù)學(xué)成績(jī):");/按高等數(shù)學(xué)成績(jī)查找scanf("%d",&Math);p=head;while(p!=NULL)(if(Math=p->Math)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);p=p->next;break;case6:(printf("請(qǐng)輸入英語(yǔ)成績(jī):"
33、);/按英語(yǔ)成績(jī)查找scanf("%d",&English);p=head;while(p!=NULL)(if(English=p->English)printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);p=p->next;break;default:(printf(-指令錯(cuò)誤返回二級(jí)菜單!n");Menu_2();break;/*-*/structstudent*Modify(structs
34、tudent*head)(intn;structstudent*p;charname24;intnum;printf("您想以何種方式進(jìn)行修改:n");printf("1;n");printf("2:學(xué)號(hào)n");printf("0:返回二級(jí)菜單n");scanf("%d",&n);switch(n)(case1:(printf(-請(qǐng)輸入:");/按查找后修改信息scanf("%s",name);p=head;while(strcmp(name,p->n
35、ame)!=0&&p->next!=NULL)p=p->next;if(strcmp(name,p->name)=0)scanf("%s%d%s%d%d%d”,p->name,&p->num,p->sex,&p->Chinese,&p->Math,&p->English);printf("修改后:n");printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p-&
36、gt;Math,p->English);elseprintf("查無(wú)此人!n");break;case2:printf("請(qǐng)輸入學(xué)號(hào):");/按學(xué)號(hào)查找后修改信息scanf("%d",&num);p=head;while(num!=p->num&&p->next!=NULL)p=p->next;if(num=p->num)scanf("%s%d%s%d%d%d",p->name,&p->num,p->sex,&p->Chi
37、nese,&p->Math,&p->English);printf("修改后:n");printf("%s%d%s%d%d%dn",p->name,p->num,p->sex,p->Chinese,p->Math,p->English);elseprintf("查無(wú)此人!n");break;default:printf("指令錯(cuò)誤,返回二級(jí)菜單!n");Menu_2();break;returnhead;structstudent*Add(struct
38、student*head)增加學(xué)生信息structstudent*p,*q;/為增加的學(xué)生分配存structstudent*add=(structstudent*)malloc(sizeof(structstudent);scanf("%s%d%s%d%d%d”,add->name,&add->num,add->sex,&add->Chinese,&add->Math,&add->English);q=head;if(head=NULL)head=add;/空表插入add->next=NULL;elsewhil
39、e(add->num>q->num)&&(q->next!=NULL)/指向下個(gè)節(jié)點(diǎn)p=q;q=q->next;if(add->num<=q->num)/插至U首節(jié)點(diǎn)if(head=q)head=add;elsep->next=add;/插到中間節(jié)點(diǎn)add->next=q;elseq->next=add;/插至U尾節(jié)點(diǎn)add->next=NULL;returnhead;structstudent*Delete(structstudent*head)/刪除學(xué)生信息intn;structstudent*p,*q;charname24;intnum;printf("您想以何種方式進(jìn)行刪除:n");printf("1;n");printf("2:學(xué)號(hào)n");printf("0:返回二級(jí)菜單n");scanf("%d",&n);switch(n)case1:printf(-請(qǐng)輸入:");/按查找并刪除scanf("%s",name);p=head;while(strcmp(name,p->name)!=0&&am
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024北京廣渠門中學(xué)高二9月月考數(shù)學(xué)試題及答案
- 2025年中學(xué)物理教師招聘考試試題與答案
- 2025年中小學(xué)教師職業(yè)道德考試試題及答案
- IT公司銷售培訓(xùn):構(gòu)建高效銷售團(tuán)隊(duì)的關(guān)鍵策略
- 腫瘤的中醫(yī)防治
- 2025年機(jī)械設(shè)計(jì)與制造基礎(chǔ)知識(shí)測(cè)試題及答案
- 人教版高中地理必修第二冊(cè) 第五章環(huán)境與發(fā)展 第二節(jié)走向人地協(xié)調(diào)可持續(xù)發(fā)展 課件
- 北京市中學(xué)關(guān)村中學(xué)2025年英語(yǔ)八下期末學(xué)業(yè)水平測(cè)試試題含答案
- 2025年財(cái)務(wù)管理專業(yè)課程考試試題及答案
- 2025年兒童心理學(xué)研究員考試試題及答案分享
- T/CCOA 45-2023氣膜鋼筋混凝土球形倉(cāng)儲(chǔ)糧技術(shù)規(guī)程
- GB/T 27772-2025病媒生物密度控制水平蠅類
- 《船舶行業(yè)重大生產(chǎn)安全事故隱患判定標(biāo)準(zhǔn)》解讀與培訓(xùn)
- 2025年中考生物模擬考試卷(附答案)
- 公路工程課件大學(xué)
- 初中歷史人教部編版八年級(jí)上冊(cè)第18課 從九一八事變到西安事變教學(xué)設(shè)計(jì)
- 11《大家排好隊(duì)》(教學(xué)設(shè)計(jì))2023-2024學(xué)年統(tǒng)編版道德與法治二年級(jí)上冊(cè)
- 新供應(yīng)商引入基本門檻標(biāo)準(zhǔn)
- 2025年河南省洛陽(yáng)市中考一模歷史試題(含答案)
- 2025年度專業(yè)技術(shù)人員繼續(xù)教育公需科目考試題(附答案)
- 光學(xué)工程師試題及答案
評(píng)論
0/150
提交評(píng)論