收藏 分销(赏)

C教师信息标准管理系统.doc

上传人:天**** 文档编号:3031769 上传时间:2024-06-13 格式:DOC 页数:22 大小:132.04KB 下载积分:10 金币
下载 相关 举报
C教师信息标准管理系统.doc_第1页
第1页 / 共22页
C教师信息标准管理系统.doc_第2页
第2页 / 共22页


点击查看更多>>
资源描述
一、 课程设计问题描述 学院教学信息管理系统是高等学校教务管理关键组成部分,其内容较多,为了简化计论,要求设计管理系统能够完成以下功效: (1)输入:输入每一位老师统计,将其信息写入文件中; (2)显示:显示每位老师统计; (3)排序:按职员号或教学效果综合评分进行排序,并显示; (4)查找:完成按姓名或课程查找老师相关统计,并显示; (5)创建:创建新纪录,输入数位老师统计,显示在屏幕上并保留; 二、 课程设计目标和要求: 经过一个学期《C++面向对象实用教程》课程学习,已经有了一定地程序设计基础,不过要学好C++程序设计,不仅要认真阅读书本知识和从事课堂学习,更关键是要进行上机实践,经过上机实践才能增强和巩固知识。 三、 系统设计(算法分析) 1、 整体结构 整个程序定义四个类 (1) CPerson类:包含数据组员name,age,sex,统计姓名,年纪,性别这些信息,并包含结构函数及其它组员函数(定义CPerson类以后若有需要,可再经过继承派生其它类); (2) CTeacher:共有继承CPerson类,包含数据组员title,teano,course,score,分别统计职称,职员号,3门课程和教学效果综合评分等信息,另有其它组员函数; (3) CNode类:节点类,包含2个数据组员,CTeacher类对象p和CNode类指针对象next,作为构建链表单位; (4) CList类:链表类,申明为CNode类友元类,数据组员有头结点head,尾节点tail,统计目前节点p和目前节点前一节点pre,链表相关输入,显示,排序,查找,创建全部设为组员函数。 总体步骤为先打开文件,读取文件中统计来创建链表,然后对链表进行操作,最终保留至文件中 2、步骤图 开始 打开文件 读取统计 输入choice choice==0? 是 否 查找 排序 创建新纪录 添加统计 显示目前统计 保留 是 保留 否 结束 3、 各函数功效和实现 学院教学信息管理系统相关功效由对应函数来实现。 (1) 输入老师信息并显示 void Append() 经过提醒一步步输入信息,由程序构建新节点并加入链表 (2) 显示全部统计 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" #include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <cstring> #include <string> using namespace std; class CPerson { private: string name; int age; char sex; public: CPerson() {} CPerson(string name,int age=0,char sex='M') { this->name=name; 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'?"男":"女")<<endl; } string GetName() { return name; } int GetAge() { return age; } char GetSex() { return sex; } }; class CTeacher:public CPerson { private: 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 SetData(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()<<"\t"<<GetAge()<<"\t"<<(GetSex()=='M'?"男":")<<title<<"\t"<<course[0]<<"\t"<<course[1]<<"\t"<<course[2]<<"\t"<<score<<endl; } void operator =(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() { return course; } string GetTitle() { return title; } string GetTeano() { return teano; } float GetScore() { return score; } }; class CNode { friend class CList; private: CTeacher data; CNode *next; }; class CList { private: CNode *head; CNode *tail; CNode *p; CNode *pre; int num;//目前节点数 public: int MainMenu() { cout<<"1.显示目前统计"<<endl; cout<<"2.添加统计"<<endl; cout<<"3.排序"<<endl; cout<<"4.查找"<<endl; cout<<"5.创建新纪录"<<endl; cout<<"0.退出"<<endl; cout<<endl; int choice; cin>>choice; return choice; } void MainMenuControl() { ReadData(); while ( 1 ) { int choice=MainMenu(); if ( 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; num=0; char fname[80]; cout<<"请输入要读取文件:"; cin>>fname; ifstream file(fname); if ( !file ) { cout<<"出现未知错误造成无法打开!"<<endl; exit(1); } string name,title,teano,course[3]; int age; char sex; float score; while ( file.peek()!=EOF ) { file>>teano>>name>>age>>sex>>title>>course[0]>>course[1]>>course[2]>>score; p=new CNode; 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; } void Print() { 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):"; 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 course[3]; cin>>course[0]>>course[1]>>course[2]; p->data.SetCourse(course[0],course[1],course[2]); cout<<"教学效果综合评分:"; float score; cin>>score; p->data.SetScore(score); p->next=tail->next; tail->next=p; tail=p; num++; char c; cout<<"是否继续添加?(Y/N):"; cin>>c; cin.get(); if ( c!='y' ) 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(); 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 SortByTeano() { 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=newp; } 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; 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!=NULL; p=p->next) if ( p->data.GetName()==name ) { p->data.ShowInfo(); n++; } if ( n==0 ) cout<<"没有相关统计"<<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=p->data.GetCourse(); for (int i=0; i<3; i++) if ( c==course[i]) { p->data.ShowInfo(); n++; break; } } if ( n==0 ) cout<<"没有相关统计"<<endl; cout<<endl; } void NewList() { Destory(); head=tail=new CNode; head->next=NULL; while ( 1 ) { p=new CNode; cout<<"请输入:"<<endl; cout<<"姓名:"; 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<<"职员号:"; string teano; cin>>teano; p->data.SetData(title,teano); cout<<"教讲课程:"; string course[3]; cin>>course[0]>>course[1]>>course[2]; p->data.SetCourse(course[0],course[1],course[2]); cout<<"教学效果综合评分:"; float score; cin>>score; p->data.SetScore(score); tail->next=p; tail=p; num++; cout<<"是否继续输入?(Y/N):"; char c; cin>>c; cin.get(); if ( c!='y' ) break; } tail->next=NULL; } void Save() { char fname[80]; cout<<"保留到:"; cin>>fname; ofstream file(fname); if ( !file ) { cout<<"出现未知错误造成无法打开!"<<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(); } void Destory() { for ( p=head->next; p!=NULL; p=head->next) { head->next=p->next; delete p; } delete head; head=NULL; tail=NULL; pre=NULL; num=0; } ~CList() { for ( p=head->next; p!=NULL; p=head->next) { head->next=p->next; delete p; } delete head; head=NULL; tail=NULL; pre=NULL; } }; int main(int argc, char* argv[]) { CList list1; list1.MainMenuControl(); CList list2; list2.MainMenuControl(); return 0; 五、缺点 1.每次全部要读取文件中统计,若是只想创建新统计,则此部多出; 2.判定文件末尾语句file.peek()!=EOF,当文件末尾为图一所表示是可正常读取完,若图二所表示,则会多读一次; 图一 图二 3.没有控制输出格式,输出格式混乱,不美观; 4.输入时没有错误输入检测,所以必需正确输入才能确保程序正常运行,如输入文件名时必需完全正确,输入性别是必需输入M/F。
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 包罗万象 > 大杂烩

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服