




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、實驗二實驗項目名稱:線性表的基本操作實驗項目的和要求:掌握線性表的特點掌握線性表的順序存儲結(jié)構(gòu)和鏈式存儲結(jié)構(gòu)的基本運算。盡可能考慮算法的健壯性實驗報告中要寫出測試數(shù)據(jù)、錯誤分析以及收獲。上機實驗內(nèi)容四:運動會記分子系統(tǒng)或?qū)W生成績管理子系統(tǒng)1參加運動會的N個學校編號為1N。比賽分成M個男子項目和W個女子項目,每個項目取前3名,得分分別為5,3,2。寫一個程序產(chǎn)生各種成績單和得分報表。完成功能包括如卞:產(chǎn)生一總成績表,包括:系名、男子團體總分、女子團體總分、團體總分存儲結(jié)構(gòu)要求用線性表的順序存儲。實驗報告中要寫出測試數(shù)據(jù)、錯誤分析以及收獲。若選擇學生成績管理子系統(tǒng),可仿照運動會記分子系統(tǒng)完成相關(guān)的
2、插入、刪除、查找及各種統(tǒng)計工作。實驗代碼如下:#include#include#include#include#definenull0#definelengthsizeof(structstudent)structstudentintstuid;charstuname20;charstusex2;floatenglish;floatmath;floatdatabase;floatsum;floataverage;structstudentFext;;structstudent*Insert(intn)pl-sum=pl-english+plmath+pldatabase;structstude
3、nt*head/*pl/*p2;for(inti=O;istuid);printf(scanf(,%s,pl-stuname);printf(scanf(,%s,pl-stusex);printf(scanf(,%f,&pl-english);printf(scanf(,%f,&pl-math);printf(n請輸入學生的學號:J;請輸入學生的姓名:J;請輸入學生的性別:J;請輸入學生的英語成績:J;請輸入學生的高數(shù)成績:);請輸入學生的數(shù)據(jù)結(jié)構(gòu)成績:H);scanf(,%f,&pl-database);pl-average=pl-sum;head=pl;p2sum=p2english+p2
4、math+p2database;plonext二null;p2sum=p2english+p2math+p2database;p2sum=p2english+p2math+p2database;else*請輸入第:1個學生的信息printf(nprintf(*nJ+l);printf(p2=(structstudent*)malloc(sizeof(structstudent);printf(請輸入學生的學號:“);scanf(,%d,&p2-stuid);printf(請輸入學生的姓名:“);scanf(,%s,p2-stuname);printf(請輸入學生的性別:“);scanf(,%s
5、,p2-stusex);printf(請輸入學生的英語成績:);scanf(,%f,&p2-english);printf(請輸入學生的高數(shù)成績:);scanf(,%f,&p2-math);printf(請輸入學生的數(shù)據(jù)結(jié)構(gòu)成績:);scanf(,%f,&p2-database);p2average=p2-sum;plnext=p2;scanf(吆化&pl-database);pl=p2;p2next=null;returnhead;voidSinsert(structstudent*head)structstudent*pl,*p2;p2=head;pl=(structstudent*)ma
6、lloc(sizeof(structstudent);printf(請輸入學生的學號:);scanf(吆d:&plstuid);printf(請輸入學生的姓名:);scanf(,%s,/pl-stuname);printf(請輸入學生的性別:);scanf(,%s,/pl-stusex);printf(請輸入學生的英語成績:“);scanf(%化&pl-english);printf(請輸入學生的高數(shù)成績:“);scanf(,%f,l/&pl-math);printf(請輸入學生的數(shù)據(jù)結(jié)構(gòu)成績:“);pl-sum=pl-english+plmath+pldatabase;pl-average=
7、pl-sum;訐(head=二null)head=pl;plnext=null;elsewhile(p2-next!=null)p2=p2-next;if(p2-next!=null)plnext=p2-next;p2next=pl;elsep2next=pl;plnext=null;voidprintln()printf(HprintfC*printf(u宣*穴*穴*穴*穴*穴*宣*宣*穴*穴*穴*穴*宣穴*穴*穴*穴*n“)*歡迎使用學生管理系統(tǒng)*n);printf(11*)stuid!二num&p-next!二null)q=p;p=p-next;if(p-stuid=num)if(p=h
8、ead)head=p-next;elseqnext=p-next;printf(#被刪除學生的信息#nn“);printf(”);printfC學號姓名性別英語高數(shù)數(shù)據(jù)結(jié)構(gòu)總分平均分W11);printf(%d%s%s%6.1f%6.1f%6.1f%6.1f%6.1fnn,p-stuid/p-stunamezp-stusex,p-english,p-math/p-database,p-sum,p-average,p-sum/p-average);printf(H)/free(p);elseprintf(M#友情提示!找不到該用戶的資料!voidSearch(structstudent*head
9、,intnum)structstudent*p;p=head;if(p=二null)printf(H#友情提示!鏈表為空#扒nnJ;elsewhile(p!=null)if(p-stuid=二num)構(gòu)總分printf(-);printf(H學號平均分nn);姓名性別英語高數(shù)數(shù)據(jù)結(jié)printfC%d%s%s%6.1f%6.1f%6.1f%6.1f%6.1fnn,p-stuid,p-stunamezp-stusex,p-english/p-math/p-database,p-sum,p-average,p-sum/paverage);printf(N);elseprintf(#友情提示!沒有該用
10、戶的信息#nn”);p=p-next;voidclass_average(structstudent*head)structstudent*pl;pl=head;floati=0,e=0zm=0,d=0;if(pl=null)printfC*#友情提示,該系統(tǒng)中沒有用戶!#”);floatenglishl=O,mathl=O,database。;while(pl!=null)i+;englishl=englishl+pl-english;if(pl-english=60)e+;mathl=mathl+pl-math;if(pl-math=60)m+;databasel=databasel+pl
11、-database;if(pl-database=60)d+;pl=pl-next;floatavel=englishl/i;floatave2=mathl/i;floatave3=databasel/i;printfC1xok*n)printff1*各科均分及及格率的查詢*nH);printff1*nn)printf(),printff1英語高數(shù)數(shù)據(jù)結(jié)構(gòu)nnH);printf(均分:%6.1f%6.1f%6.1fnnH,avel,ave2zave3);printfC及格率:%6lf%61俠%nn,/e/iUOO,m/i*100,d/i*100);printf();voidResult_sor
12、t(structstudent*head)inti=0;structstudentend;structstudent*p;structstudent*pl;structstudent*p2;structstudent*p3;pl=(structstudent*)malloc(length);plnext=head;head=pl;for(end=null;end!=head;end=p)for(p=pl=head;plnext-next!=end;pl=pl-next)if(pl-next-sumnextnext-sum)p2=plnextnext;plnext-next=p2next;p2n
13、ext=pl-next;plnext=p2;p=plnext-next;pl=head;head=head-next;free(pl);p3=head;printff學號姓名性別英語高數(shù)數(shù)據(jù)結(jié)構(gòu)總分平均分nn);printf(Hwhile(p3!=null)printf(H%d%s%s%6.1f%6.1f%6.1f%6.1f%6.1f%dnnzp3-stuid/p3-stuname/p3-stusex,p3-english,p3math,p3database,p3sum,p3average,p3-sum,p3-average);p3=p3-next;printf(H);voidshow_max
14、(structstudent*head)printf(H宣*穴)()4(*宣穴*穴*穴*宣穴*穴*穴*穴*宣*宣*穴*宣穴*穴*)4(*穴*穴*宣穴*n“)printfC*各科最高分學生信息*n);printfCprintff11);structstudent*pl,*p2,*p3;floatmaxl=0,max2=0,max3=0;for(pl=head;pl-next!=null;pl=pl-next)訐(pl-englishplnextenglish)maxl=pl-english;elsemaxl=pl-next-english;for(p2=head;p2-next!=null;p2
15、=p2-next)if(p2-mathp2-next-math)max2=p2-math;elsemax2=p2-next-math;for(p3=head;p3-next!=null;p3=p3-next)訐(p3-databasep3-next-database)max3=p3-database;elsemax3=p3-next-database;printf(H英語:%6.1fnn,maxl);printf(高數(shù):%6.1fnn/max2);printf(數(shù)據(jù)結(jié)構(gòu):%6.1fnn,max3);printfl11-voidmain()println();structstudent*head
16、;while(l)printf(H#請輸入您要進行的操作#nrf);inti;scanf(”d”,&i);switch(i)case1:intn;printf(#請輸入您要批量的個數(shù):#nn”);scanf(“2d“,&n);head=lnsert(n);break;case2:Sinsert(head);break;case3:intnum2;printf(#請輸入要查找學生的學號:scanf(”10cT:&num2);Search(head,num2);break;case4:intnuml;printf(#請輸入要刪除學生的學號scanfflOd&numl);Delete(head,nu
17、ml);break;case5:Result_sort(head);break;case6:show_max(head);break;case7:class_average(head);break;case&printf(printf(N#感謝您使用一再見printf(return;break;歡迎使用學注管理系統(tǒng)U1.批星添加學生信息3杳找某個學注XXKK5按成績進行排名?各舉均分及及恪率X-X-X-XXX洛WXXM-彳洛WXXM-彳洛WXXM-彳洛WXXM-WX,XXXMXXKXXMXXKXXMXXKXXMXXMXXXXMXKXXXMXKXXXMXKXXXMXKXX2插入單個學生K4冊J除
18、某個學生K6顯示各科最rSj分xxxx8退出管理系統(tǒng)*二二,t:ttHSH333一tt入入入入入入ttttinM01-s-冃請tt22舊訕/+r工h丁丈入侶二口n兀豈:o75ttttttttttttttttttttit輸入您要逬行的操作tttttttttttttttttttttt3ttttttttttttttttttlt輸入要查找學生的學號.tttttttttttttttttttt101學號姓名性別英語高數(shù)數(shù)據(jù)結(jié)構(gòu)總分平均分101wunanMMB11.022.033.066.022.0tttttttttttttttttttt請輸入您要進行的操作Itttttttttlttttttttttt學號姓名性別英語高數(shù)數(shù)據(jù)結(jié)構(gòu)總分平均分103dongnan44.085.065.0194.064.71102jiannv22.055.088.0165.055.00101VIUnan11.022.033.066.022.00ttttttS#tt#it224IUHUUU-U4IU-HU作3nq-n咸進威成結(jié)您號名別i入的的的的的的請4二土.fcM二土二二41dTr占呂斗與i瓷吹入X入ix4llt請請請請請請呱各科均分及及格率的查詢英語高數(shù)數(shù)據(jù)結(jié)構(gòu)均分:25.?54.062.0及格率:0.0Z33.3z66.7
溫馨提示
- 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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 旅行學習與研學活動安排計劃
- 社會實踐小班社區(qū)活動的開展計劃
- 人力資源的發(fā)展與管理計劃
- 2025年企業(yè)管理服務(wù)項目建議書
- 2025年白喉、百日咳、破傷風、乙肝四聯(lián)制劑合作協(xié)議書
- 跨國業(yè)務(wù)數(shù)據(jù)轉(zhuǎn)換合規(guī)指南
- 基于人工智能的智能家居設(shè)計合作協(xié)議
- 服裝設(shè)計行業(yè)服裝設(shè)計版權(quán)協(xié)議
- 2025年抗帕金森病藥項目建議書
- Pipemidic-acid-trihydrate-Standard-生命科學試劑-MCE
- 春季開學安全第一課PPT、中小學開學第一課教育培訓主題班會PPT模板
- JJG30-2012通用卡尺檢定規(guī)程
- 部編版人教版二年級上冊語文教材分析
- 小學英語微課ppt
- APR版制作流程
- 《C++程序設(shè)計》完整教案
- 美國LM2500艦用燃氣輪機
- 《公共政策分析》課件.ppt
- RNA-seq研究方法與策略-zzz
- 醫(yī)用耗材分類目錄 (低值 ╱ 高值)
- 公司名稱預(yù)先核準通知書
評論
0/150
提交評論