C學(xué)生成績管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第1頁
C學(xué)生成績管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第2頁
C學(xué)生成績管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第3頁
C學(xué)生成績管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第4頁
C學(xué)生成績管理系統(tǒng)課程設(shè)計(jì)報(bào)告_第5頁
已閱讀5頁,還剩28頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

年4月19日C學(xué)生成績管理系統(tǒng)課程設(shè)計(jì)報(bào)告文檔僅供參考一.目的與要求經(jīng)過本課程設(shè)計(jì)的實(shí)踐,全面總結(jié)C++課程學(xué)習(xí)中的的數(shù)據(jù)類型、程序結(jié)構(gòu)、數(shù)組、函數(shù)、指針、結(jié)構(gòu)體、鏈表等基本概念,掌握其使用方法。掌握面向?qū)ο蟪绦蛟O(shè)計(jì)中有關(guān)類、對(duì)象、繼承、重載、多態(tài)性、輸入輸出流類體系、文件操作的基本概念,初步學(xué)會(huì)用類與對(duì)象這種面向?qū)ο蟮某绦蛟O(shè)計(jì)方法編寫應(yīng)用程序。培養(yǎng)使用面向?qū)ο蟮某绦蛟O(shè)計(jì)方法編寫計(jì)算機(jī)程序的能力。經(jīng)過設(shè)計(jì)一個(gè)《學(xué)生成績統(tǒng)計(jì)管理》,進(jìn)一步熟悉C++中類的概念、類的封裝、繼承的實(shí)現(xiàn)方式。了解系統(tǒng)開發(fā)的需求分析、類層次設(shè)計(jì)、模塊分解、編碼測試、模塊組裝與整體調(diào)試的全過程,加深對(duì)C++的理解與VisualC++環(huán)境的使用;逐步熟悉程序設(shè)計(jì)的方法,并養(yǎng)成良好的編程習(xí)慣。程序設(shè)計(jì)是一門實(shí)踐性很強(qiáng)的課程,必須十分重視實(shí)踐環(huán)節(jié)。許多實(shí)際的知識(shí)不是靠聽課和看書學(xué)到的,而是經(jīng)過長時(shí)間的實(shí)踐積累的。設(shè)計(jì)內(nèi)容學(xué)生成績管理系統(tǒng)基本功能:這個(gè)程序的主要功能是輸入學(xué)生姓名、成績,學(xué)號(hào),并能夠?qū)W(xué)生的成績按學(xué)號(hào)進(jìn)行查詢。該系統(tǒng)具有存貯學(xué)生數(shù)據(jù),按學(xué)號(hào)按需要修改學(xué)生成績,列出學(xué)生成績和統(tǒng)計(jì)功能。擴(kuò)展功能:學(xué)生數(shù)據(jù)的添加、修改、與刪除2.E—R修改數(shù)據(jù)修改數(shù)據(jù)刪除數(shù)據(jù)查詢數(shù)據(jù)顯示數(shù)據(jù)平均數(shù)據(jù)添加數(shù)據(jù)學(xué)生成績管理系統(tǒng)過程與結(jié)果主要內(nèi)容如下:關(guān)鍵類的設(shè)計(jì),繼承層次關(guān)系,代碼:首先,創(chuàng)立了一個(gè)student類.Student類的聲明如下:classStudent{public: intClass,num; charname[8]; floatcpp,math,eng,ave; intorder; Student*next;public: Student(){}Student(intc1,intn1,char*n,floate1,floatc2,floatm,floate2,floats,floatp,floata, into,Student*next=NULL) { Class=c1;num=n1; strcpy(name,n); cpp=c2;math=m;eng=e2;ave=a; order=o; this->next=next; }主要功能函數(shù)的設(shè)計(jì):創(chuàng)立學(xué)生數(shù)據(jù),對(duì)學(xué)生的成績的錄入。 代碼:friendStudent*Create(Student*head,istream&in) {inty; Student*p; intClass,num; charname[8]; floatcpp,math,eng; if(&in==&cin) //cout<<"\n\n請(qǐng)輸入學(xué)生數(shù)據(jù)(輸入成績非法,則結(jié)束),數(shù)據(jù)輸入格式為:\n" //<<"班級(jí)姓名學(xué)號(hào)C++數(shù)學(xué)英語\n"; //in>>Class>>name>>num>>cpp>>math>>eng; //cout<<"\n\n請(qǐng)輸入學(xué)生數(shù)據(jù):\n" cout<<"班級(jí):"<<endl; in>>Class;cout<<"姓名:"<<endl;in>>name; cout<<"學(xué)號(hào):"<<endl;in>>num; cout<<"C++的成績:"<<endl;in>>cpp; cout<<"數(shù)學(xué)的成績:"<<endl;in>>math; cout<<"英語的成績:"<<endl;in>>eng; /*while(Valid(elec)&&Valid(cpp)&&Valid(math)&&Valid(eng)&&Valid(sport)&&Valid(polity)) {*/p=newStudent; p->Class=Class;p->num=num;strcpy(p->name,name); p->cpp=cpp;p->math=math; p->eng=eng; p->ave=(cpp+math+eng)/6; head=Insert(head,p); //in>>Class>>name>>num>>elec>>cpp>>math>>eng>>polity>>sport; cout<<"\t\t*****繼續(xù)添加請(qǐng)按1*******\n"; cout<<"\t\t*****返回主菜單請(qǐng)按2*******\n"; in>>y;if(y==2) { ShowMenu(); } else{head=Create(head,cin);} SetOrder(head);//設(shè)置排名 returnhead; } 此函數(shù)為查找函數(shù)的實(shí)現(xiàn)過程 主要代碼:friendconstStudent*Lookup(constStudent*head,intnum)//查找指定學(xué)號(hào)為num的結(jié)點(diǎn) { while(head&&head->num!=num) head=head->next; returnhead; } friendvoidOutputOne(constStudent*head)//輸出一個(gè)學(xué)生數(shù)據(jù) { cout<<head->Class<<'\t'<<head->name<<'\t'<<head->num<<'\t' <<head->cpp<<'\t'<<head->math<<'\t' <<head->eng<<'\t' <<head->order<<endl; } 3.此函數(shù)為刪除函數(shù)的實(shí)現(xiàn)部分。 主要代碼:friendStudent*DeleteStudent(Student*head,intnum) { Student*p1=head,*p2=p1; while(p2&&p2->num!=num) p1=p2,p2=p2->next; if(p2) { if(p2==p1) { head=head->next;deletep1; } else { p1->next=p2->next;deletep2; } cout<<"已刪除"<<num<<"號(hào)學(xué)生數(shù)據(jù)\n"; SetOrder(head); }elsecout<<"沒找到指定學(xué)生!\n"; returnhead; } 4.排序函數(shù)中平均分來排序,排序結(jié)果為降序操作。 friendvoidSetOrder(Student*head) { intorder=1; while(head) {head->order=order++;head=head->next;} }5.修改學(xué)生的信息friendStudent*Modify(Student*head,intnum)//修改學(xué)號(hào)為學(xué)生的數(shù)據(jù) { Student*p1=head,*p2=p1; while(p2&&p2->num!=num)//尋找待修改的結(jié)點(diǎn) p1=p2,p2=p2->next; if(p2)//修改指定結(jié)點(diǎn)數(shù)據(jù) { /*cout<<"\n\n請(qǐng)輸入新數(shù)據(jù),格式為:\n" <<"班級(jí)姓名學(xué)號(hào)C++數(shù)學(xué)英語\n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng;*/ cout<<"班級(jí):"<<endl; cin>>p2->Class;cout<<"姓名:"<<endl;cin>>p2->name; cout<<"學(xué)號(hào):"<<endl;cin>>p2->num; cout<<"C++的成績:"<<endl;cin>>p2->cpp; cout<<"數(shù)學(xué)的成績:"<<endl;cin>>p2->math; cout<<"英語的成績:"<<endl;cin>>p2->eng; while(!Valid(p2->cpp)||!Valid(p2->math)||!Valid(p2->eng) ) { cout<<"\n\n成績數(shù)據(jù)非法!請(qǐng)重新輸入,格式為:\n" <<"班級(jí)姓名學(xué)號(hào)C++數(shù)學(xué)英語\n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng; } p2->ave=(p2->cpp+p2->math+p2->eng)/3; //將修改的指定結(jié)點(diǎn)從原鏈表上修改下來,并重新降序插入原鏈表 if(p2==p1) head=Insert(p2->next,p2); else { p1->next=p2->next; head=Insert(head,p2); } SetOrder(head); } elsecout<<"沒找到指定學(xué)生!\n"; returnhead; } 6.顯示數(shù)據(jù): friendvoidOutputAll(constStudent*head)//輸出所有學(xué)生的數(shù)據(jù) { if(!head){cout<<"\n\n\t\t沒有任何學(xué)生數(shù)據(jù)!\n\n";return;} cout<<"\n\n\t\t學(xué)生成績表\n\n"; cout<<"班級(jí)\t姓名\t學(xué)號(hào)\tC++\t數(shù)學(xué)\t英語\t名次\n"; while(head) { OutputOne(head);head=head->next; } }7.平均數(shù)據(jù)函數(shù) friendvoidStatistic(constStudent*head) { inti=0; float ave_cpp=0, ave_math=0, ave_eng=0; while(head) { ave_cpp+=head->cpp; ave_math+=head->math; ave_eng+=head->eng; i++;head=head->next; } if(!i) { cout<<"\n\n沒有任何學(xué)生數(shù)據(jù)!\n";return;} cout<<"\n\n\t\t各門課程平均成績表\n\n"; cout<<"tC++\t數(shù)學(xué)\t英語\n"; cout<<ave_cpp/i<<'\t'<<ave_math/i<<'\t' <<ave_eng/i<<endl; }程序測試結(jié)果:1運(yùn)行程序.會(huì)出現(xiàn)如下畫面,按照提示進(jìn)行選擇.首先選擇1,然后按Enter鍵.按照提示對(duì)學(xué)生情況進(jìn)行輸入.如圖:按1鍵能夠添加多個(gè)學(xué)生成績的數(shù)據(jù),按2返回主界面。選擇5,然后按Enter鍵,顯示剛才輸入的數(shù)據(jù)和排名的情況。5在主界面選擇2能夠修改學(xué)生的數(shù)據(jù)。6.在主界面選擇3能夠按學(xué)號(hào)查詢學(xué)生成績情況7.在主界面選擇7能夠按學(xué)號(hào)刪除學(xué)生的成績信息設(shè)計(jì)總結(jié)這次課程設(shè)計(jì)基本上涵蓋了學(xué)習(xí)到的C++語言知識(shí)點(diǎn),課程設(shè)計(jì)題目要求不但要求對(duì)課本雖然是網(wǎng)上搜來的代碼,但這些代碼沒辦法運(yùn)行,我把這些代碼改了和增加了自己寫的代碼,終于能夠運(yùn)行,而且到達(dá)自己想要的結(jié)果,這次課程設(shè)計(jì)不但讓我修補(bǔ)了以前學(xué)習(xí)的漏洞,也讓我知道一個(gè)道理:編程需要興趣和實(shí)際動(dòng)手。C++語言程序設(shè)計(jì)課程設(shè)計(jì),我從中受益匪淺,而且對(duì)C++語言程序設(shè)計(jì)這一門課程有了更深一步的認(rèn)識(shí)。附件程序源代碼清單:#include<fstream.h>#include<string.h>classStudent{public: intClass,num; charname[8]; floatcpp,math,eng,ave; intorder; Student*next;public: Student(){}Student(intc1,intn1,char*n,floate1,floatc2,floatm,floate2,floats,floatp,floata, into,Student*next=NULL) { Class=c1;num=n1; strcpy(name,n); cpp=c2;math=m;eng=e2;ave=a; order=o; this->next=next; } friendintValid(floatscore) { return(score<0||score>100)?0:1; } friendvoidSetOrder(Student*head) { intorder=1; while(head) {head->order=order++;head=head->next;} } friendStudent*Insert(Student*head,Student*p)//在head所指的鏈表中降序插入結(jié)點(diǎn)p { Student*p1,*p2; if(head==0) { head=p;p->next=0; } elseif(head->ave<=p->ave) { p->next=head;head=p; } else { p2=p1=head; while(p2->next&&p2->ave>p->ave) { p1=p2;p2=p2->next; } if(p2->ave>p->ave) { p2->next=p;p->next=0; } else{ p->next=p2;p1->next=p; } } returnhead; } friendStudent*Create(Student*head,istream&in) {inty; Student*p; intClass,num; charname[8]; floatcpp,math,eng; if(&in==&cin) //cout<<"\n\n請(qǐng)輸入學(xué)生數(shù)據(jù)(輸入成績非法,則結(jié)束),數(shù)據(jù)輸入格式為:\n" //<<"班級(jí)姓名學(xué)號(hào)C++數(shù)學(xué)英語\n"; //in>>Class>>name>>num>>cpp>>math>>eng; //cout<<"\n\n請(qǐng)輸入學(xué)生數(shù)據(jù):\n" cout<<"班級(jí):"<<endl; in>>Class;cout<<"姓名:"<<endl;in>>name; cout<<"學(xué)號(hào):"<<endl;in>>num; cout<<"C++的成績:"<<endl;in>>cpp; cout<<"數(shù)學(xué)的成績:"<<endl;in>>math; cout<<"英語的成績:"<<endl;in>>eng; /*while(Valid(elec)&&Valid(cpp)&&Valid(math)&&Valid(eng)&&Valid(sport)&&Valid(polity)) {*/p=newStudent; p->Class=Class;p->num=num;strcpy(p->name,name); p->cpp=cpp;p->math=math; p->eng=eng; p->ave=(cpp+math+eng)/6; head=Insert(head,p); //in>>Class>>name>>num>>elec>>cpp>>math>>eng>>polity>>sport; cout<<"\t\t*****繼續(xù)添加請(qǐng)按1*******\n"; cout<<"\t\t*****返回主菜單請(qǐng)按2*******\n"; in>>y;if(y==2) { ShowMenu(); } else{head=Create(head,cin);} SetOrder(head);//設(shè)置排名 returnhead; } friendconstStudent*Lookup(constStudent*head,intnum)//查找指定學(xué)號(hào)為num的結(jié)點(diǎn) { while(head&&head->num!=num) head=head->next; returnhead; } friendvoidOutputOne(constStudent*head)//輸出一個(gè)學(xué)生數(shù)據(jù) { cout<<head->Class<<'\t'<<head->name<<'\t'<<head->num<<'\t' <<head->cpp<<'\t'<<head->math<<'\t' <<head->eng<<'\t' <<head->order<<endl; } friendvoidOutputAll(constStudent*head)//輸出所有學(xué)生的數(shù)據(jù) { if(!head){cout<<"\n\n\t\t沒有任何學(xué)生數(shù)據(jù)!\n\n";return;} cout<<"\n\n\t\t學(xué)生成績表\n\n"; cout<<"班級(jí)\t姓名\t學(xué)號(hào)\tC++\t數(shù)學(xué)\t英語\t名次\n"; while(head) { OutputOne(head);head=head->next; } } friendStudent*Modify(Student*head,intnum)//修改學(xué)號(hào)為學(xué)生的數(shù)據(jù) { Student*p1=head,*p2=p1; while(p2&&p2->num!=num)//尋找待修改的結(jié)點(diǎn) p1=p2,p2=p2->next; if(p2)//修改指定結(jié)點(diǎn)數(shù)據(jù) { /*cout<<"\n\n請(qǐng)輸入新數(shù)據(jù),格式為:\n" <<"班級(jí)姓名學(xué)號(hào)C++數(shù)學(xué)英語\n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng;*/ cout<<"班級(jí):"<<endl; cin>>p2->Class;cout<<"姓名:"<<endl;cin>>p2->name; cout<<"學(xué)號(hào):"<<endl;cin>>p2->num; cout<<"C++的成績:"<<endl;cin>>p2->cpp; cout<<"數(shù)學(xué)的成績:"<<endl;cin>>p2->math; cout<<"英語的成績:"<<endl;cin>>p2->eng; while(!Valid(p2->cpp)||!Valid(p2->math)||!Valid(p2->eng) ) { cout<<"\n\n成績數(shù)據(jù)非法!請(qǐng)重新輸入,格式為:\n" <<"班級(jí)姓名學(xué)號(hào)C++數(shù)學(xué)英語\n"; cin>>p2->Class>>p2->name>>p2->num>>p2->cpp>>p2->math >>p2->eng; } p2->ave=(p2->cpp+p2->math+p2->eng)/3; //將修改的指定結(jié)點(diǎn)從原鏈表上修改下來,并重新降序插入原鏈表 if(p2==p1) head=Insert(p2->next,p2); else { p1->next=p2->next; head=Insert(head,p2); } SetOrder(head); } elsecout<<"沒找到指定學(xué)生!\n"; returnhead; } friendStudent*DeleteStudent(Student*head,intnum) { Student*p1=head,*p2=p1; while(p2&&p2->num!=num) p1=p2,p2=p2->next; if(p2) { if(p2==p1) { head=head->next;deletep1; } else { p1->next=p2->next;deletep2; } cout<<"已刪除"<<num<<"號(hào)學(xué)生數(shù)據(jù)\n"; SetOrder(head); }elsecout<<"沒找到指定學(xué)生!\n"; returnhead; } friendvoidStatistic(constStudent*head) { inti=0; float ave_cpp=0, ave_math=0, ave_eng=0; while(head) { ave_cpp+=head->cpp; ave_math+=head->math; ave_eng+=head->eng; i++;head=head->next; } if(!i) { cout<<"\n\n沒有任何學(xué)生數(shù)據(jù)!\n";return;} cout<<"\n\n\t\t各門課程平均成績表\n\n"; cout<<"tC++\t數(shù)學(xué)\t英語\n"; cout<<ave_cpp/i<<'\t'<<ave_math/i<<'\t' <<ave_eng/i<<endl; } friendvoidDeleteChain(Student*head) {Student*p; while(head) { p=head;head=head->next;deletep; } } friendvoidShowMenu(void) { cout<<"\n\n"; cout<<"\t\t******歡迎使用學(xué)生成績管理系統(tǒng)******\n" <<"\t\t**\n" <<"\t\t*1.從鍵盤錄入與添加數(shù)據(jù)*\n" // <<"\t\t*2.從文件錄入與添加數(shù)據(jù)*\n" <<"\t\t*2.修改數(shù)據(jù)*\n" <<"\t\t*3.查詢數(shù)據(jù)*\n" <<"\t\t*4.刪除數(shù)據(jù)*\n" <<"\t\t*5.顯示數(shù)據(jù)*\n" <<"\t\t*6.平均數(shù)據(jù)*\n" // <<"\t\t*7.保存數(shù)據(jù)*\n" <<"\t\t**\n" <<"\t\t*0.退出系統(tǒng)*\n" <<"\t\t**********************************\n\n"; }};voidmain(void){ Student*head=0; intselect; while(1)

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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)論