數(shù)據(jù)結(jié)構(gòu)課程設(shè)計_第1頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計_第2頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計_第3頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計_第4頁
數(shù)據(jù)結(jié)構(gòu)課程設(shè)計_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

需求分析說明此題對學(xué)生的某門課程成績管理做一個簡單的模擬,為了實現(xiàn)學(xué)生成績的管理與分析,設(shè)計一個學(xué)生成績管理系統(tǒng)。學(xué)生信息包括:學(xué)號、姓名、性別,要確保其信息的準(zhǔn)確性。課程的成績信息有平時成績、實驗成績、期未成績、總評成績,總評成績=平時成績*0.4+實驗成績*0.3+期末成績*0.3,用菜單項選擇擇方式完成以下功能:〔1〕登記學(xué)生成績;〔2〕插入學(xué)生成績;〔3〕修改學(xué)生成績;〔4〕刪除學(xué)生成績;〔5〕查詢學(xué)生成績;〔6〕對學(xué)生成績進(jìn)行排序;〔7〕輸出學(xué)生成績。在完成上述根本要求的操作后,要應(yīng)用功能〔6〕進(jìn)行測試。總體設(shè)計設(shè)計功能表如下:〔附:功能解釋〕學(xué)生成績管理1、輸入學(xué)生成績〔輸入學(xué)生的根本信息:學(xué)號、姓名、性別和成績信息〕2、插入學(xué)生成績〔按照學(xué)號進(jìn)行所需信息的插入〕3、修改學(xué)生成績〔對其學(xué)生信息和成績信息根據(jù)一定的需求進(jìn)行修改〕4、刪除個人信息〔按照學(xué)號進(jìn)行刪除〕5、查詢個人成績〔按照學(xué)號進(jìn)行刪除〕6、學(xué)生成績排名〔升序排名〕7、查詢?nèi)w信息〔顯示全體學(xué)生的學(xué)生信息及成績信息〕8、查看成績排名〔排名后顯示成績排名〕詳細(xì)設(shè)計系統(tǒng)功能分析:學(xué)生信息包括:學(xué)號、姓名、性別,要確保其信息的準(zhǔn)確性。課程的成績信息有平時成績、實驗成績、期未成績、總評成績,總評成績=平時成績*0.4+實驗成績*0.3+期末成績*0.3,以及功能上述功能。在完成上術(shù)根本要求的操作后,要應(yīng)用功能〔6〕進(jìn)行測試。得出該題目以創(chuàng)立兩個類,一個類保存成績信息:平時成績、實驗成績、期未成績、總評成績,一個類保存學(xué)生信息:學(xué)號姓名、性別。從功能分析可知該存儲方式適合用鏈表存儲結(jié)構(gòu):此類功能中在未排序前應(yīng)該以學(xué)號為主鍵,排序后應(yīng)該以總評成績?yōu)橹麈I?!?〕定義一個成績類:classscore{public:〔訪問控制屬性〕,平時成績〔floatpeacetime〕,實驗成績〔floatexperiment〕,期末成績〔floatfinal〕,總評成績〔floattotal〕}〔2〕定義一個學(xué)生類:Classstudentpublic:〔訪問控制屬性〕,intsno〔學(xué)號〕,stringname〔姓名〕stringsex〔性別〕scorecourse〔課程〕student*next〔下一個學(xué)生地址指針〕student*registed();//登記學(xué)生成績voidinsert(student*s,inti);//插入學(xué)生成績voidalter(student*s,inti);//修改學(xué)生成績voiddeleted(student*s,inti);//刪除學(xué)生成績voidseek(student*s,inti);//查詢學(xué)生成績student*sort(student*s);//成績排序voidprint(student*s);//輸出學(xué)生成績voidsortprint(student*s);//排序后的成績輸出;存儲結(jié)構(gòu)設(shè)計分析學(xué)生的信息:學(xué)生的信息和成績信息都儲存在一個鏈表里,每個節(jié)點表示一個學(xué)生的信息,包括學(xué)號,姓名及平時成績〔floatpeacetime〕,實驗成績〔floatexperiment〕,期末成績〔floatfinal〕,總評成績〔floattotal〕等數(shù)據(jù)項。程序流程圖開始開始菜單菜單學(xué)生成績管理學(xué)生成績管理8查看成績排名7查詢?nèi)w信息6學(xué)生成績排名5查詢個人成績8查看成績排名7查詢?nèi)w信息6學(xué)生成績排名5查詢個人成績4刪除個人信息3修改學(xué)生成績2插入學(xué)生成績1輸入學(xué)生成績退出退出代碼#include<iostream>#include<iomanip>#include<string>usingnamespacestd;classscore{public:floatpeacetime;//平時成績floatexperiment;//實驗成績floatfinal;//期末成績floattotal;//總評成績};classstudent{public:intsno;//學(xué)號stringname;//姓名stringsex;//性別scorecourse;//課程student*next;student*registed();//登記學(xué)生成績voidinsert(student*s,inti);//插入學(xué)生成績voidalter(student*s,inti);//修改學(xué)生成績voiddeleted(student*s,inti);//刪除學(xué)生成績voidseek(student*s,inti);//查詢學(xué)生成績student*sort(student*s);//成績排序voidprint(student*s);//輸出學(xué)生成績voidsortprint(student*s);//排序后的成績輸出};student*student::registed(){inte;student*hm2,*p,*r;r=hm2=newstudent;hm2->next=NULL;cout<<"輸入需要登記的學(xué)生的個數(shù):";cin>>e;for(inti=1;i<=e;i++){p=newstudent;cout<<"輸入學(xué)生的學(xué)號:";cin>>p->sno;cout<<"輸入學(xué)生姓名:";cin>>p->name;cout<<"輸入學(xué)生性別:";cin>>p->sex;cout<<"輸入平時成績";cin>>p->course.peacetime;cout<<"輸入實驗成績";cin>>p->course.experiment;cout<<"輸入期末成績";cin>>p->course.final;p->course.total=static_cast<float>(p->course.peacetime*0.4+p->course.experiment*0.3+p->course.final*0.3);cout<<"課程的總評成績:"<<p->course.total<<endl;hm2->next=p;hm2=p;}hm2->next=NULL;returnr;}voidstudent::insert(student*s,inti){student*p,*q;p=s;while((p->next!=NULL)&&(p->next->sno<i))p=p->next;q=newstudent;q->sno=i;cout<<"輸入學(xué)生姓名:";cin>>q->name;cout<<"輸入學(xué)生性別:";cin>>q->sex;cout<<"輸入平時成績";cin>>q->course.peacetime;cout<<"輸入的實驗成績";cin>>q->course.experiment;cout<<"輸入期末成績";cin>>q->course.final;q->course.total=static_cast<float>(q->course.peacetime*0.4+q->course.experiment*0.3+q->course.final*0.3);cout<<endl;cout<<"課程的總評成績:"<<q->course.total<<endl;q->next=p->next;p->next=q;}voidstudent::alter(student*s,inti){student*p;p=s;while((p->next!=NULL)&&(p->next->sno!=i))p=p->next;if(p->next==NULL){ cout<<"未找到學(xué)號,修改失敗。"<<endl; return;}else{ cout<<"學(xué)生學(xué)號:"<<p->next->sno<<endl; cout<<"學(xué)生姓名:"<<p->next->name<<endl; cout<<"學(xué)生性別:"<<p->next->sex<<endl; cout<<"輸入平時成績"; cin>>p->next->course.peacetime; cout<<"輸入實驗成績"; cin>>p->next->course.experiment; cout<<"輸入期末成績"; cin>>p->next->course.final; p->next->course.total=static_cast<float>(p->next->course.peacetime*0.4+p->next->course.experiment*0.3+p->next->course.final*0.3); cout<<endl; cout<<"課程的總評成績:"<<p->next->course.total<<endl;}}voidstudent::deleted(student*s,inti){student*p;p=s;while((p->next!=NULL)&&(p->next->sno!=i)){p=p->next;}if(p->next==NULL){ cout<<"沒有該學(xué)號。"<<endl;return;}p->next=p->next->next;}voidstudent::seek(student*s,inti){student*p;p=s;while((p->next!=NULL)&&(p->next->sno!=i))p=p->next;if(p->next==NULL){ cout<<"未找到該學(xué)生信息"<<endl; return;}else{ cout<<"學(xué)生學(xué)號:"<<p->next->sno<<endl; cout<<"學(xué)生姓名:"<<p->next->name<<endl; cout<<"學(xué)生性別:"<<p->next->sex<<endl; cout<<"平時成績"<<p->next->course.peacetime<<endl; cout<<"實驗成績"<<p->next->course.experiment<<endl; cout<<"期末成績"<<p->next->course.final<<endl; cout<<"總評成績:"<<p->next->course.total<<endl;}}voidstudent::print(student*s){student*p;p=s->next;if(p==NULL) cout<<"當(dāng)前沒有學(xué)生信息。"<<endl;else do {cout<<"學(xué)生學(xué)號:"<<p->sno<<endl;cout<<"學(xué)生姓名:"<<p->name<<endl;cout<<"學(xué)生性別:"<<p->sex<<endl;cout<<"平時成績"<<p->course.peacetime<<endl;cout<<"實驗成績"<<p->course.experiment<<endl;cout<<"期末成績"<<p->course.final<<endl;cout<<"總評成績:"<<p->course.total<<endl;cout<<endl;p=p->next; }while(p!=NULL);}student*student::sort(student*s){ student*t,*m,*s1,*q; chary; t=newstudent; t->next=NULL; q=s->next; if(q==NULL) cout<<"還沒有學(xué)生信息!"<<endl; else do { m=t; s1=newstudent; s1->name=q->name; s1->sex=q->sex; s1->sno=q->sno; s1->course.peacetime=q->course.peacetime; s1->course.experiment=q->course.experiment; s1->course.final=q->course.final; s1->course.total=q->course.total; while((m->next!=NULL)&&(m->next->course.total>s1->course.total)) m=m->next; s1->next=m->next; m->next=s1; q=q->next; }while(q!=NULL);cout<<"是否輸出學(xué)生成績排名?(y/n)"; cin>>y; if(y=='y') sortprint(t); returnt; }voidstudent::sortprint(student*s)//輸出排名后的成績{ student*t; t=s->next; while(t!=NULL) { cout<<"學(xué)號:"<<t->sno<<"姓名:"<<t->name<<"性別:"<<t->sex<<"總評:"<<t->course.total<<endl; t=t->next; }}intmain(){ inti,j; chary; studentt; student*hm1; student*hm; hm=NULL; hm1=NULL;loop:cout<<"+++++++++++++學(xué)生成績管理+++++++++++++++"<<endl; cout<<endl;cout<<"1、輸入學(xué)生成績"<<endl;cout<<"2、插入學(xué)生成績"<<endl;cout<<"3、修改學(xué)生成績"<<endl;cout<<"4、刪除個人信息"<<endl;cout<<"5、查詢個人成績"<<endl;cout<<"6、學(xué)生成績排名"<<endl;cout<<"7、查詢?nèi)w信息"<<endl;cout<<"8、查看成績排名"<<endl;cout<<endl;cout<<"輸入需要進(jìn)行操作的前面的序號:";cin>>i; switch(i){ case1:cout<<"登記學(xué)生成績"<<endl;hm=t.registed();break;case2:cout<<"插入學(xué)生成績"<<endl;loop4:cout<<"輸入插入成績的學(xué)生的學(xué)號:";cin>>j;t.insert(hm,j);cout<<"是否繼續(xù)插入學(xué)生成績?(y/n)";cin>>y;if(y=='y') gotoloop4;break;case3:cout<<"修改學(xué)生成績"<<endl;loop1:cout<<"輸入修改成績的學(xué)生的學(xué)號:";cin>>j;t.alter(hm,j); cout<<"是否繼續(xù)修改?(y/n)"; cin>>y; if(y=='y') gotoloop1;break;case4:cout<<"刪除個人成績"<<endl;loop2:cout<<"輸入刪除成績的學(xué)生的學(xué)號:";cin>>j;t.deleted(hm,j);cout<<"是否繼續(xù)刪除?(y/n)";cin>>y;if(y=='y') gotoloop2;break;case5:cout<<"查詢個人成績"<<endl;loop3:cout<<"輸入查詢成績的學(xué)生的學(xué)號:";cin>>j;t.seek(hm,j);cout<<"是否繼續(xù)查詢學(xué)生成績?(y/n)"; cin>>y;if(y=='y') gotoloop3;break;case6: cout<<"學(xué)生成績排名"<<endl; hm1=t.sort(hm); break;case7: cout<<"查詢?nèi)w信息"<<endl; t.print(hm); break;case8: if(hm1!=NULL) { cout<<"查看成績排名"<<endl; t.sortprint(hm1); } else cout<<"還未進(jìn)行排名"; break;default:cout<<"輸入有誤";} cout<<endl<<"是否返回主頁面繼續(xù)管理操作?"<<endl; cout<<"yesorno(y/n)?"<<endl; cin>>y; if(y=='y') {system("cls");gotoloop;} else { system("cls"); cout<<endl<<endl<<endl<<endl<<endl<<endl; cout<<endl<<setw(6)<<"****************歡送下次光臨!**************"<<endl; system("pause"); return0; }}程序測試程序界面輸入學(xué)生成績插入學(xué)生成績〔插入學(xué)號為05的學(xué)生的學(xué)生信息及成績信息〕查看結(jié)果:修改學(xué)生成績修改后的刪除個人信息已刪除學(xué)號為1的學(xué)生信息查詢個人成績學(xué)生成績排名查詢?nèi)w信息查看成績排名總結(jié)通過這次的課程設(shè)計,知道做一個程序設(shè)計,真的不容易

溫馨提示

  • 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

提交評論