




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、一、 課程設(shè)計問題描述學院教學信息管理系統(tǒng)是高等學校教務(wù)管理的重要組成部分,其內(nèi)容較多,為了簡化計論,要求設(shè)計的管理系統(tǒng)能夠完成以下功能:(1)輸入:輸入每一位教師記錄,將其信息寫入文件中;(2)顯示:顯示每位教師記錄;(3)排序:按職工號或教學效果綜合評分進行排序,并顯示;(4)查找:完成按姓名或課程查找教師的相關(guān)記錄,并顯示;(5)創(chuàng)建:創(chuàng)建新的紀錄,輸入數(shù)位教師記錄,顯示在屏幕上并保存;二、 課程設(shè)計目的和要求:經(jīng)過一個學期的C+面向?qū)ο髮嵱媒坛陶n程的學習,已經(jīng)有了一定地程序設(shè)計基礎(chǔ),但是要學好C+程序設(shè)計,不僅要認真閱讀課本知識和從事課堂學習,更重要的是要進行上機實踐,通過上機實踐才能
2、增強和鞏固知識。三、 系統(tǒng)設(shè)計(算法分析)1、 整體結(jié)構(gòu)整個程序定義四個類(1) CPerson類:包含數(shù)據(jù)成員name,age,sex,記錄姓名,年齡,性別這些信息,并包含構(gòu)造函數(shù)及其他成員函數(shù)(定義CPerson類以后若有需要,可再通過繼承派生其他類);(2) CTeacher:共有繼承CPerson類,包含數(shù)據(jù)成員title,teano,course,score,分別記錄職稱,職工號,3門課程和教學效果綜合評分等信息,另有其他成員函數(shù);(3) CNode類:節(jié)點類,包含2個數(shù)據(jù)成員,CTeacher類對象p和CNode類指針對象next,作為構(gòu)建鏈表的單位;(4) CList類:鏈表類,
3、聲明為CNode類的友元類,數(shù)據(jù)成員有頭結(jié)點head,尾節(jié)點tail,記錄當前節(jié)點的p和當前節(jié)點前一節(jié)點的pre,鏈表相關(guān)的輸入,顯示,排序,查找,創(chuàng)建全部設(shè)為成員函數(shù)??傮w流程為先打開文件,讀取文件中的記錄來創(chuàng)建鏈表,然后對鏈表進行操作,最后保存至文件中- 1 - / 162、流程圖開始打開文件讀取記錄輸入choicechoice=0? 是 否查找排序創(chuàng)建新紀錄添加記錄顯示當前記錄保存 是保存 否結(jié)束3、 各函數(shù)的功能和實現(xiàn)學院教學信息管理系統(tǒng)的相關(guān)功能由對應的函數(shù)來實現(xiàn)。(1) 輸入教師信息并顯示void Append()通過提示一步步輸入信息,由程序構(gòu)建新節(jié)點并加入鏈表(2) 顯示所有記
4、錄void Print()(3)按職工號或教學效果綜合評分排序并顯示int SortMenu()void SortMenuControl()void InsertByTeano(CNode *newp)void SortByTeano()void InsertByScore(CNode *newp)void SortByScore()(4)按姓名或課程查找教師記錄并顯示int SearchMenu()void SearchMenuControl()void SearchByName()void SearchByCourse()四、程序源代碼#include "stdafx.h&quo
5、t;#include <iostream>#include <fstream>#include <vector>#include <algorithm>#include <cstring>#include <string>using namespace std;class CPersonprivate:string name;int age;char sex;public:CPerson()CPerson(string name,int age=0,char sex='M')this->name=na
6、me;this->age=age;this->sex=sex;void SetAge(int age=0)this->age=age;void SetNameAndSex(string name,char sex)this->name=name;this->sex=sex;void ShowInfo()cout<<name<<"t"<<age<<"t"<<(sex='M'?"男":"女")<<end
7、l;string GetName()return name;int GetAge()return age;char GetSex()return sex;class CTeacher:public CPersonprivate:string title;/職稱string teano;/職工號vector<string> course;/教授課程float score;/教學效果綜合評分public:CTeacher()CTeacher(string name,int age=0,char sex='M'):CPerson(name,age,sex)void Set
8、Data(string title,string teano)this->title=title;this->teano=teano;void SetCourse(string c1,string c2,string c3)course.push_back(c1);course.push_back(c2);course.push_back(c3);void SetScore(float score)this->score=score;void ShowInfo()cout<<teano<<"t"<<GetName()&l
9、t;<"t"<<GetAge()<<"t"<<(GetSex()='M'?"男":")<<title<<"t"<<course0<<"t"<<course1<<"t"<<course2<<"t"<<score<<endl;void operator =(CTeacher
10、&one)CPerson(one.GetName(),one.GetAge(),one.GetSex();this->title=one.title;this->teano=one.teano;this->course0=one.course0;this->course1=one.course1;this->course2=one.course2;this->score=one.score;vector<string> GetCourse()return course;string GetTitle()return title;strin
11、g GetTeano()return teano;float GetScore()return score;class CNodefriend class CList;private:CTeacher data;CNode *next;class CListprivate:CNode *head;CNode *tail;CNode *p;CNode *pre;int num;/當前節(jié)點數(shù)public:int MainMenu()cout<<"1.顯示當前記錄"<<endl;cout<<"2.添加記錄"<<e
12、ndl;cout<<"3.排序"<<endl;cout<<"4.查找"<<endl;cout<<"5.創(chuàng)建新紀錄"<<endl;cout<<"0.退出"<<endl;cout<<endl;int choice;cin>>choice;return choice;void MainMenuControl()ReadData();while ( 1 )int choice=MainMenu();if
13、( choice=0 )break;switch ( choice )case 1:Print();break;case 2:Append();break;case 3:SortMenuControl();break;case 4:SearchMenuControl();break;case 5:NewList();break;cout<<"是否保存?(Y/N):"char c;cin>>c;if ( c='y' )Save();void ReadData()head=tail=new CNode;head->next=NULL
14、;num=0;char fname80;cout<<"請輸入要讀取的文件:"cin>>fname;ifstream file(fname);if ( !file )cout<<"出現(xiàn)未知錯誤導致無法打開!"<<endl;exit(1);string name,title,teano,course3;int age;char sex;float score;while ( file.peek()!=EOF )file>>teano>>name>>age>>sex
15、>>title>>course0>>course1>>course2>>score;p=new CNode;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);p->data.SetData(title,teano);p->data.SetCourse(course0,course1,course2);p->data.SetScore(score);tail->next=p;tail=p;num+;tail->next=NULL;void P
16、rint()for ( p=head->next; p!=NULL; p=p->next)p->data.ShowInfo();cout<<endl;void Append()while ( 1 )p=new CNode;cout<<"請輸入:"<<endl;cout<<"姓名:"string name;cin>>name;cout<<"年齡:"int age;cin>>age;cout<<"性別(F/M):&q
17、uot;char sex;cin>>sex;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);cout<<"職稱:"string title;cin>>title;cout<<"職工號:"string teano;cin>>teano;p->data.SetData(title,teano);cout<<"教授課程:"string course3;cin>>course0>&
18、gt;course1>>course2;p->data.SetCourse(course0,course1,course2);cout<<"教學效果綜合評分:"float score;cin>>score;p->data.SetScore(score);p->next=tail->next;tail->next=p;tail=p;num+;char c;cout<<"是否繼續(xù)添加?(Y/N):"cin>>c;cin.get();if ( c!='y'
19、 )break;tail->next=NULL;Print();int SortMenu()cout<<"1.按職工號排序"<<endl;cout<<"2.按教學效果綜合評分排序"<<endl;cout<<"0.退出"<<endl;cout<<endl;int choice;cin>>choice;return choice;void SortMenuControl()while ( 1 )int choice=SortMenu();
20、if ( choice=0 )break;switch ( choice )case 1:SortByTeano();break;case 2:SortByScore();break;Print();void InsertByTeano(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;void SortBy
21、Teano()p=head->next;head->next=NULL;CNode *nextp;while ( p!=NULL )nextp=p->next;InsertByTeano(p);p=nextp;void InsertByScore(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=ne
22、wp;void SortByScore()p=head->next;head->next=NULL;CNode *nextp;while ( p!=NULL )nextp=p->next;InsertByScore(p);p=nextp;int SearchMenu()cout<<"1.按姓名查找"<<endl;cout<<"2.按課程查找"<<endl;cout<<"0.退出"<<endl;cout<<endl;int choice
23、;cin>>choice;return choice;void SearchMenuControl()while ( 1 )int choice=SearchMenu();if ( choice=0 )break;switch ( choice )case 1:SearchByName();break;case 2:SearchByCourse();break;void SearchByName()int n=0;cout<<"請輸入姓名:"string name;cin>>name;for ( p=head->next; p!=N
24、ULL; p=p->next)if ( p->data.GetName()=name)p->data.ShowInfo();n+;if ( n=0 )cout<<"沒有相關(guān)記錄"<<endl;cout<<endl;void SearchByCourse()int n=0;cout<<"請輸入查找課程:"string c;cin>>c;for ( p=head->next; p!=NULL; p=p->next)vector<string> course=
25、p->data.GetCourse();for (int i=0; i<3; i+)if ( c=coursei)p->data.ShowInfo();n+;break;if ( n=0 )cout<<"沒有相關(guān)記錄"<<endl;cout<<endl;void NewList()Destory();head=tail=new CNode;head->next=NULL;while ( 1 )p=new CNode;cout<<"請輸入:"<<endl;cout<&
26、lt;"姓名:"string name;cin>>name;cout<<"年齡:"int age;cin>>age;cout<<"性別(F/M):"char sex;cin>>sex;p->data.SetNameAndSex(name,sex);p->data.SetAge(age);cout<<"職稱:"string title;cin>>title;cout<<"職工號:"strin
27、g teano;cin>>teano;p->data.SetData(title,teano);cout<<"教授課程:"string course3;cin>>course0>>course1>>course2;p->data.SetCourse(course0,course1,course2);cout<<"教學效果綜合評分:"float score;cin>>score;p->data.SetScore(score);tail->next=p
28、;tail=p;num+;cout<<"是否繼續(xù)輸入?(Y/N):"char c;cin>>c;cin.get();if ( c!='y' )break;tail->next=NULL;void Save()char fname80;cout<<"保存到:"cin>>fname;ofstream file(fname);if ( !file )cout<<"出現(xiàn)未知錯誤導致無法打開!"<<endl;exit(1);for ( p=head->next; p!=NULL; p=p->next)vector<string> course=p->data.GetCourse();file<<p->data.GetTeano(
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- T/ZHCA 604-2023消毒產(chǎn)品中激素含量的測定液相色譜-串聯(lián)質(zhì)譜法
- 2025西北工業(yè)大學輔導員考試試題及答案
- 2025遼寧職業(yè)學院輔導員考試試題及答案
- 2025貴州水利水電職業(yè)技術(shù)學院輔導員考試試題及答案
- 2025貴陽信息科技學院輔導員考試試題及答案
- 2025牡丹江師范學院輔導員考試試題及答案
- 2025白城師范學院輔導員考試試題及答案
- 食堂食品衛(wèi)生管理
- 新疆水發(fā)準水建設(shè)開發(fā)有限公司招聘筆試題庫2025
- T/YWEISA 001-2022裝配式不銹鋼水處理構(gòu)筑物安裝技術(shù)規(guī)程
- 2025年電信工程師考試卷及答案
- 英語系學生學習總結(jié)模版
- 2024年蘇州科技大學輔導員考試真題
- 湖南省煙草專賣局(公司)筆試試題2024
- 2025-2030年中國聚四氟乙烯(PTFE)行業(yè)市場現(xiàn)狀供需分析及投資評估規(guī)劃分析研究報告
- 2024年玉門市市屬事業(yè)單位考試真題
- 2025云南中考:語文必考知識點
- 2025小米SU7事件高速爆燃事故輿情復盤
- 玻璃體積血試題及答案
- 會議系統(tǒng)維保服務(wù)方案投標文件(技術(shù)方案)
- 遼寧點石聯(lián)考2025屆高三5月份聯(lián)合考試-政治試卷+答案
評論
0/150
提交評論