版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
課程設(shè)計(jì)問題描述學(xué)院教學(xué)信息管理系統(tǒng)是高等學(xué)校教務(wù)管理的重要組成部分,其內(nèi)容較多為了簡化計(jì)論,要求設(shè)計(jì)的管理系統(tǒng)能夠完成以下功能:(1)輸入:輸入每一位教師記錄,將其信息寫入文件中;(2)顯示:顯示每位教師記錄;(3)排序:按職工號(hào)或教學(xué)效果綜合評(píng)分進(jìn)行排序,并顯示;(4)查找:完成按姓名或課程查找教師的相關(guān)記錄,并顯示;(5)創(chuàng)建:創(chuàng)建新的紀(jì)錄,輸入數(shù)位教師記錄,顯示在屏幕上并保存;二、課程設(shè)計(jì)目的和要求:經(jīng)過一個(gè)學(xué)期的《C++面向?qū)ο髮?shí)用教程》課程的學(xué)習(xí),已經(jīng)有了一定地程序設(shè)計(jì)基礎(chǔ),但是要學(xué)好C++程序設(shè)計(jì),不僅要認(rèn)真閱讀課本知識(shí)和從事課堂學(xué)習(xí),更重要的是要進(jìn)行上機(jī)實(shí)踐,通過上機(jī)實(shí)踐才能增強(qiáng)和鞏固知識(shí)。三、系統(tǒng)設(shè)計(jì)(算法分析)1、整體結(jié)構(gòu)整個(gè)程序定義四個(gè)類(1)CPerson類:包含數(shù)據(jù)成員name,age,sex,記錄姓名,年齡,性別這些信息,并包含構(gòu)造函數(shù)及其他成員函數(shù)(定義CPerson類以后若有需要,可再通過繼承派生其他類);(2)CTeacher:共有繼承CPerson類,包含數(shù)據(jù)成員title,teano,course,score,分別記錄職稱,職工號(hào),3門課程和教學(xué)效果綜合評(píng)分等信息,另有其他成員函數(shù);(3)CNode類:節(jié)點(diǎn)類,包含2個(gè)數(shù)據(jù)成員,CTeacher類對(duì)象p和CNode類指針對(duì)象next,作為構(gòu)建鏈表的單位;(4)CList類:鏈表類,聲明為CNode類的友元類,數(shù)據(jù)成員有頭結(jié)點(diǎn)head,尾節(jié)點(diǎn)tail,記錄當(dāng)前節(jié)點(diǎn)的p和當(dāng)前節(jié)點(diǎn)前一節(jié)點(diǎn)的pre,鏈表相關(guān)的輸入,顯示,排序,查找,創(chuàng)建全部設(shè)為成員函數(shù)??傮w流程為先打開文件,讀取文件中的記錄來創(chuàng)建鏈表,然后對(duì)鏈表進(jìn)行操作,最后保存至文件中2、流程打開文件讀取記錄打開文件讀取記錄否t結(jié)束3、各函數(shù)的功能和實(shí)現(xiàn)學(xué)院教學(xué)信息管理系統(tǒng)的相關(guān)功能由對(duì)應(yīng)的函數(shù)來實(shí)現(xiàn)(1)輸入教師信息并顯示voidAppend()通過提示一步步輸入信息,由程序構(gòu)建新節(jié)點(diǎn)并加入鏈表2)顯示所有記錄voidPrint()(3)按職工號(hào)或教學(xué)效果綜合評(píng)分排序并顯示intSortMenu()voidSortMenuControl()voidInsertByTeano(CNode*newp)voidSortByTeano()voidInsertByScore(CNode*newp)voidSortByScore()(4)按姓名或課程查找教師記錄并顯示intSearchMenu()voidSearchMenuControl()voidSearchByName()voidSearchByCourse()四、程序源代碼#include"stdafx.h"#include<iostream>{{{{#include<fstream>#include<vector>#include<algorithm>#include<cstring>#include<string>usingnamespacestd;classCPerson{private:stringname;intage;charsex;public:CPerson(){}CPerson(stringname,intage=0,charsex='M')this->name=name;this->age=age;}}}}{{{{this->sex=sex;voidSetAge(intage=0){this->age=age;}voidSetNameAndSex(stringname,charsex){this->name=name;this->sex=sex;}voidShowInfo(){cout<<name<<"\t"<<age<<"\t"<<(sex=='M?男":"女")<<endl;}stringGetName()returnname;}}}}intGetAge(){returnage;}charGetSex(){returnsex;}};classCTeacher:publicCPerson{private:stringtitle;//職稱stringteano;//職工號(hào)vector<string>course;//教授課程floatscore;//教學(xué)效果綜合評(píng)分public:{{{{CTeacher(){}CTeacher(stringname,intage=0,charsex='M'):CPerson(name,age,sex){}voidSetData(stringtitle,stringteano){this->title=title;this->teano=teano;}voidSetCourse(stringc1,stringc2,stringc3){course.push_back(c1);course.push_back(c2);course.push_back(c3);}voidSetScore(floatscore)this->score=score;}}}}{{{{voidShowInfo(){cout<<teano<<"\t"<<GetName()<<"\t"<<GetAge()<<"\t"<<(GetSex()=='M'?"男":")<<title<<"\t"<<course[0]<<‘\t"<<course[1]<<"\t"<<course[2]<<"\t"<<score<<endl;}voidoperator=(CTeacher&one){CPerson(one.GetName(),one.GetAge(),one.GetSex());this->title=one.title;this->teano=one.teano;this->course[0]=one.course[0];this->course[1]=one.course[1];this->course[2]=one.course[2];this->score=one.score;}vector<string>GetCourse()returncourse;}}}}{{{{stringGetTitle(){returntitle;}stringGetTeano(){returnteano;}floatGetScore(){returnscore;}};classCNodefriendclassCList;private:CTeacherdata;CNode*next;};classCList{private:CNode*head;CNode*tail;CNode*p;CNode*pre;intnum;//當(dāng)前節(jié)點(diǎn)數(shù)public:intMainMenu(){cout<<"1.顯示當(dāng)前記錄"<<endl;cout<<"2.添加記錄"<<endl;cout<<"3.排序"<<endl;cout<<"4.查找"<<endl;cout<<"5.創(chuàng)建新紀(jì)錄"<<endl;cout<<"0.退出"<<endl;cout<<endl;intchoice;cin>>choice;returnchoice;}voidMainMenuControl(){ReadData();while(1){intchoice=MainMenu();if(choice==0)break;switch(choice){case1:Print();break;case2:Append();break;case3:SortMenuControl();break;case4:SearchMenuControl();break;case5:NewList();break;cout<<堤否保存?(Y/N):charc;cin>>c;if(c=='y')Save();}voidReadData(){head=tail=newCNode;head->next=NULL;num=0;charfname[80];cout<<"請(qǐng)輸入要讀取的文件:";cin>>fname;ifstreamfile(fname);if(!file){cout<<"出現(xiàn)未知錯(cuò)誤導(dǎo)致無法打開!"<<endl;exit(1);}stringname,title,teano,course[3];intage;{{{{charsex;floatscore;while(file.peek()!=EOF){file>>teano>>name>>age>>sex>>title>>course[0]>>course[1]>>course[2]>>score;p=newCNode;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);p->data.SetData(title,teano);p->data.SetCourse(course[0],course[1],course[2]);p->data.SetScore(score);tail->next=p;tail=p;num++;}tail->next=NULL;}voidPrint()for(p=head->next;p!=NULL;p=p->next)p->data.ShowInfo();cout<<endl;}voidAppend(){while(1){p=newCNode;cout<<"請(qǐng)輸入:"<<endl;cout<<":";stringname;cin>>name;cout<<"年齡:";intage;cin>>age;cout<<"性別(F/M):";charsex;cin>>sex;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);cout<<"職稱:";stringtitle;cin>>title;cout<<"職工號(hào):";stringteano;cin>>teano;p->data.SetData(title,teano);cout<<"教授課程:";stringcourse[3];cin>>course[0]>>course[1]>>course[2];p->data.SetCourse(course[0],course[1],course[2]);cout<<"教學(xué)效果綜合評(píng)分:";floatscore;cin>>score;p->data.SetScore(score);p->next=tail->next;tail->next=p;tail=p;num++;charc;cout<<"是否繼續(xù)添加?(Y/N):";cin>>c;cin.get();{{{{if(c!='y')break;}tail->next=NULL;Print();}intSortMenu(){cout<<"1.按職工號(hào)排序"<<endl;cout<<"2.按教學(xué)效果綜合評(píng)分排序"<<endl;cout<<"0.退出"<<endl;cout<<endl;intchoice;cin>>choice;returnchoice;}voidSortMenuControl()while(1)intchoice=SortMenu();if(choice==0)break;switch(choice){case1:SortByTeano();break;case2:SortByScore();break;}Print();}}voidInsertByTeano(CNode*newp){for(pre=head,p=head->next;p!=NULL;pre=p,p=p->next)if(newp->data.GetTeano()<p->data.GetTeano())break;newp->next=p;pre->next=newp;}voidSortByTeano()p=head->next;head->next=NULL;CNode*nextp;while(p!=NULL){nextp=p->next;InsertByTeano(p);p=nextp;}}voidInsertByScore(CNode*newp){for(pre=head,p=head->next;p!=NULL;pre=p,p=p->next)if(newp->data.GetScore()<p->data.GetScore())break;newp->next=p;pre->next=newp;}voidSortByScore()p=head->next;head->next=NULL;CNode*nextp;{{{{while(p!=NULL){nextp=p->next;InsertByScore(p);p=nextp;}}intSearchMenu(){cout<<"1?按姓名查找"<<endl;cout<<"2.按課程查找"<<endl;cout<<"0.退出"<<endl;cout<<endl;intchoice;cin>>choice;returnchoice;}voidSearchMenuControl()while(1){{{{{intchoice=SearchMenu();if(choice==0)break;switch(choice){case1:SearchByName();break;case2:SearchByCourse();break;}}}voidSearchByName(){intn=0;cout<<"請(qǐng)輸入姓名:";stringname;cin>>name;for(p=head->next;p!=NULL;p=p->next)if(p->data.GetName()==name)p->data.ShowInfo();n++;if(n==0)cout<<"沒有相關(guān)記錄"<<endl;cout<<endl;}voidSearchByCourse(){intn=0;cout<<"請(qǐng)輸入查找課程:";stringc;cin>>c;for(p=head->next;p!=NULL;p=p->next){vector<string>course=p->data.GetCourse();for(inti=0;i<3;i++)if(c==course[i]){p->data.ShowInfo();n++;break;if(n==0)cout<<"沒有相關(guān)記錄"<<endl;cout<<endl;}voidNewList(){Destory();head=tail=newCNode;head->next=NULL;while(1){p=newCNode;cout<<"請(qǐng)輸入:"<<endl;cout<<":";stringname;cin>>name;cout<<"年齡:";intage;cin>>age;cout<<"性別(F/M):";charsex;cin>>sex;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);cout<<"職稱:";stringtitle;cin>>title;cout<<"職工號(hào):";stringteano;cin>>teano;p->data.SetData(title,teano);cout<<"教授課程:";stringcourse[3];cin>>course[0]>>course[1]>>course[2];p->data.SetCourse(course[0],course[1],course[2]);cout<<"教學(xué)效果綜合評(píng)分:";floatscore;cin>>score;p->data.SetScore(score);tail->next=p;tail=p;num++;cout<<"是否繼續(xù)輸入?(Y/N):";charc;cin>>c;cin.get();if(c!='y')break;}tail->next=NULL;}voidSave(){charfname[80];cout<<"保存到:";cin>>fname;ofstreamfile(fname);if(!file){cout<<"出現(xiàn)未知錯(cuò)誤導(dǎo)致無法打開!"<<endl;exit(1);}for(p=head->next;p!=NULL;p=p->next){vector<string>course=p->data.GetCourse();file<<p->data.GetTeano()<<"\t"<<p->data.GetName()<<"\t"<<p->data.GetAge()<<"\t"<<p->data.GetSex()<<"\t"<<p->data.GetTitle()<<"\t"<<course[0]<<"\t"<<course[1]<<"\t"<<course[2]<<"\t"<<p->data.GetScore()<<endl;}file.close();}voidDestory(){for(p=head->next;p!=NULL;p=head->next){head->next=p->next;deletep;}deletehead;head=NULL;tail=NULL;pre=NULL;num=0;}}}}~CList(){for(p=head->next;p!=NULL;p=head->next){head->next=p->next;deletep;}deletehead;head=NULL;tail=NULL;pre=NULL;}};intmain(intargc,char*argv[]){CListlist1;list1.MainMenuControl();CListlist2;list2.MainMenuControl();return
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026年西安華山金屬材料科技有限公司招聘備考題庫參考答案詳解
- 2026年鹽城經(jīng)濟(jì)技術(shù)開發(fā)區(qū)公開招聘基層醫(yī)療機(jī)構(gòu)專業(yè)技術(shù)人員6人備考題庫及1套參考答案詳解
- 2026年浙江空港數(shù)字科技有限公司工程項(xiàng)目部工程項(xiàng)目管理員(勞務(wù)派遣)招聘備考題庫完整參考答案詳解
- 北京大學(xué)2026年度應(yīng)屆畢業(yè)生公開招聘備考題庫(一)及答案詳解一套
- 2026年資陽市人才發(fā)展集團(tuán)有限公司公開招聘資陽市中心血站勞務(wù)派遣人員的備考題庫及完整答案詳解一套
- 中山大學(xué)附屬第三醫(yī)院粵東醫(yī)院2026年合同人員招聘備考題庫有答案詳解
- 2026年武漢國創(chuàng)東高新能源科技發(fā)展有限公司招聘備考題庫及完整答案詳解1套
- 2026年有編制通州這所高校招聘54人快報(bào)名備考題庫完整答案詳解
- 北京中關(guān)村科技融資擔(dān)保有限公司2026年校園招聘備考題庫及1套完整答案詳解
- 南昌大學(xué)第一附屬醫(yī)院2025年影像中心技術(shù)員崗招聘計(jì)劃備考題庫及1套完整答案詳解
- 廣州大學(xué)2026年第一次公開招聘事業(yè)編制輔導(dǎo)員備考題庫及1套參考答案詳解
- 2024-2025學(xué)年廣東省廣州市越秀區(qū)八年級(jí)上學(xué)期期末數(shù)學(xué)試卷(含答案)
- 原材料進(jìn)場(chǎng)驗(yàn)收制度規(guī)范
- 物業(yè)公司競標(biāo)方案
- 華東理工大學(xué)2026年公開招聘工作人員46名備考題庫(含答案詳解)
- 《急性主動(dòng)脈綜合征診斷與治療規(guī)范中國專家共識(shí)(2021版)》重點(diǎn)
- 校園跑腿行業(yè)數(shù)據(jù)分析報(bào)告
- 2026年焊接安全員考試真題解析
- 檢驗(yàn)科醫(yī)患溝通培訓(xùn)課件
- 勞務(wù)分包施工技術(shù)交底方案
- 2026年遼寧農(nóng)業(yè)職業(yè)技術(shù)學(xué)院單招職業(yè)技能考試題庫及答案詳解一套
評(píng)論
0/150
提交評(píng)論