c++学校人员信息管理系统_学校人员信息管理系统

2020-02-27 其他范文 下载本文

c++学校人员信息管理系统由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“学校人员信息管理系统”。

1.C++课程设计题目:《学校人员信息管理系统》

用c++设计一个大学教师和学生管理程序,教师包括编号(a),姓名(c),职称(d)和教研室数据(b)的数据输入输出;大学生包括编号(m),姓名(s),性别(t),班号(n),英语(e),高等数学(f)和数据结构(g)三门课程成绩输入输出和计算机平均分(ave);研究生包括编号,姓名,性别,班号,指导教师和研究方法数据输入输出;博士后数据的输入输出;博士后既是教师也是研究生.(用派生,继承的方法可以做)2.功能如下图所示:

学生成绩管理系统主函数主菜单录入学生信息保存信息到文件浏览学生信息按姓名或学号查询信息删除信息退出系统 3.部分代码 #include #include #include“persons.h” #include“student.h” #include“teacher.h” #include“empoyee.h” #include“chainList.h” #include void fileRead(chainList *list,ifstream &ff);//把文件从硬盘上读入内存 void fileWrite(chainList *list,ofstream &ff);//写入硬盘

int compareStr(char*str1,char*str2);//名字作为关键字,这个函数就用来比较 void addList(chainList *list);//同名的话,覆盖,或者改为新名字加入 void

deleteNode(chainList *node);//根据名字删除

void editList(chainList *list,char *name);//要编辑的人名和新的资料

chainList *searchList(chainList *list,char*name);//只提供名字查询(其他以后加入)//返回前一个节点的指针

void orderList(chainList *list);//按名字排序

void orderListByAge(chainList *list);//按年龄降序排列

void orderListBySex(chainList *list);//按照性别排列,女士优先 void printStaticInfo(chainList*list);void printList(chainList *list);int main(){cout>sn;char fileName[30];chainList headNode(0,NULL);chainList *head=&headNode;if(sn=='l'){ifstream file;

cout

cin>>fileName;

file.open(fileName);if(!file)//为何输入不存在地文件后,机子变得很慢,而且没有结果出来?

{cout

return 1;

}

// cout

fileRead(head,file);//读入文件到链表

file.close();} printStaticInfo(head);char ctn;

do {cout>ctn;switch(ctn){ case '0':break;case '1':

addList(head);

break;case '2':

cout

char nm[20];

cin>>nm;

chainList *pdel;

pdel=searchList(head,nm);

char sure;//Make sure whether you want to delete the data

sure='n';

if(!pdel->next)

{

cout

}

else{

cout

pdel->next->pl->print();

cout

cin>>sure;

if(sure=='y')

{

deleteNode(pdel);

cout

} } break;case '3': cout>nm1;chainList *pp;

pp=searchList(head,nm1);

if(pp->next)

{

cout

pp->next->pl->print();

cout

editList(head,nm1);

}

else

cout

break;

case '4':

cout

char name[30];

cin>>name;

chainList *p;

p=searchList(head,name);

if(p->next)

{

p->next->pl->print();

}

else

cout

break;

case '5':

cout

cout

3.sex(lady first)“

char ch;

cin>>ch;

switch(ch)

{

case '1':

cout

orderList(head);

printStaticInfo(head);

break;

case '2':

cout

orderListByAge(head);

printStaticInfo(head);

break;

case '3':

cout

orderListBySex(head);

printStaticInfo(head);

break;

default:

cout

}

break;

case '6':

printStaticInfo(head);

break;

default:

cout

}

}while(ctn!='0');cout>save;if(save!='n'){

cout

cin>>fileName;

ofstream fin;

fin.open(fileName);//如果文件已经存在,询问是否覆盖。如何知道是否存在if(!fin)

{

cout

return 1;

}

fileWrite(head,fin);

fin.close();

cout

void fileRead(chainList *list,ifstream &ff){ chainList*p=list;int tp;

} char nm[20];int ag;char sx;int slr;int grd;

int e;int m;int g;int average;char schl[20];char sb[20];int teaYear;int aa=1;persons*psn;//插入人员指针

ff>>tp;while(tp){ ff>>ag;

ff>>nm;

ff>>sx;

switch(tp){

case 1: ff>>grd;ff>>schl;

psn=new student(ag,nm,sx,grd,schl,e,m,g,average);

break;case 2:

ff>>sb;

ff>>teaYear;

psn=new teacher(ag,nm,sx,sb,teaYear);

break;case 3:

ff>>slr;

psn=new empoyee(ag,nm,sx,slr);

break;}

} chainList*s=new chainList(tp,psn);p->next=s;p=s;ff>>tp;void fileWrite(chainList *list,ofstream &ff){ chainList*p=list->next;while(p){

fftypeOfPnpl->agepl->namepl->sex

switch(p->typeOfPn)

{

case 1:

ffpl)->gradepl)->school

break;

case 2:

ffpl)->subjectpl)->yearsOfT

break;

case 3:

ffpl)->salary

break;

} p=p->next;} int aa=0;ff

int i=0;while((p1[i]==p2[i])&&p1[i]&&p2[i])

i++;if(p1[i]==p2[i]){

return 0;} else { if(p1[i]>p2[i])

return 1;

else

return-1;} }

void addList(chainList *list)//添加节点 {

char tp;int type;do{ cout

2.a teacher 3.a common employee”>tp;//为什么一输入字符就死循环??

char nm[20];int ag;char sx;int slr;int grd;char schl[20];

int e;int m;

int g;int average;char sb[20];int teaYear;int aa=1;persons*psn;//插入人员指针

switch(tp){ case '0':aa=0;

type=0;

break;case '1':

type=1;

cout

cin>>nm;

cout

cin>>ag;

cout

cin>>sx;

cout

cin>>grd;

cout

cin>>schl;

cout

cin>>e;

cout

cin>>m;

cout

cin>>g;

cout

psn=new student(ag,nm,sx,grd,schl,e,m,g,average);

break;

case '2':type=2;

cout

cin>>nm;

cout

cin>>ag;

cout

cin>>sx;

cout

cin>>sb;

cout

cin>>teaYear;

psn=new teacher(ag,nm,sx,sb,teaYear);

break;

case '3':type=3;

cout

cin>>nm;

cout

cin>>ag;

cout

cin>>sx;

cout

cin>>slr;

psn=new empoyee(ag,nm,sx,slr);

break;

default:type=6;

aa=0;

cout

}

chainList*p=list;//新节点在p所指的节点之前插入,if(aa)

{

int com;

if(p->next)

{

com=compareStr(nm,p->next->pl->name);

cout

}

while(p->next&&com>0)//比p节点小或者p为空退出

{

p=p->next;

if(p->next)

com=compareStr(nm,p->next->pl->name);

}

chainList *s=new chainList(type,psn);

s->next=p->next;

p->next=s;

}

}while(type);

} void deleteNode(chainList *node){

chainList*ptemp=node->next;

node->next=ptemp->next;

delete ptemp;} void editList(chainList *list,char *name)//删除,添加就是编辑。缺点:不想删除的也被删除了。{ chainList *pde;pde=searchList(list,name);

char tp;int type;do{

cout

cout

2.a teacher 3.a common employee“

cout

cin>>tp;//为什么一输入字符就死循环??

char nm[20];

int ag;

char sx;

int slr;

int grd;

char schl[20];

int e;

int m;

int g;

int average;

char sb[20];

int teaYear;

int aa=1;

persons*psn;//插入人员指针

if(tp==1||tp==2||tp==3)

deleteNode(pde);switch(tp){ case '0':aa=0;type=0;break;case '1': type=1;cout>nm;cout>ag;cout>sx;cout>grd;cout>schl;cout>e;cout>m;cout>g;psn=new student(ag,nm,sx,grd,schl,e,m,g,average);break;case '2':type=2;cout>nm;cout>ag;cout>sx;cout>sb;cout>teaYear;psn=new teacher(ag,nm,sx,sb,teaYear);break;case '3':type=3;cout>nm;

cout

cin>>ag;

cout

cin>>sx;

cout

cin>>slr;

psn=new empoyee(ag,nm,sx,slr);

break;

default:type=6;

aa=0;

cout

}

chainList*p=list;//新节点在p所指的节点之前插入,if(aa)

{

int com;

if(p->next)

{

com=compareStr(nm,p->next->pl->name);

cout

}

while(p->next&&com>0)//比p节点小或者p为空退出

{

p=p->next;

if(p->next)

com=compareStr(nm,p->next->pl->name);

}

chainList *s=new chainList(type,psn);

s->next=p->next;

p->next=s;

}

}while(type);

} chainList *searchList(chainList *list,char*name)//查找函数 { chainList *p=list;int com;if(p->next)

com=compareStr(name,p->next->pl->name);

while(p->next&&com)//com为0值(即名字相同)或者p->next为空退出

{ p=p->next;if(p->next)com=compareStr(name,p->next->pl->name);} return p;} void orderList(chainList *list){ chainList *p,*q;p=list;q=p->next;while(q->next&&p){

while((p->next!=q->next)&&p->next)//如果相等,则什么也不做

{

int i=compareStr(q->next->pl->name,p->next->pl->name);

i=-i;

if(i>0)//字母顺序小的插在前面

{

chainList*s;

s=q->next;

q->next=s->next;

s->next=p->next;

p->next=s;

p=s;

break;

}

if(i==0)//字母顺序相同的插到后面

{

chainList*;

=q->next;

q->next=->next;

p=p->next;//让p永远指向插入位置前一个位置。

->next=p->next;

p->next=;

p=;

break;

}

p=p->next;

}

p=list;//让p重新指向头节点。

if(q->next)

q=q->next;//q前进一步。

} }

void orderListByAge(chainList *list){ chainList*p,*q;p=list;q=p->next;while(q->next&&p){

while(p->next!=q->next)//如果相等,则什么也不做

{

int i=q->next->pl->age-p->next->pl->age;

if(i>0)//年龄大的插到用于比较的节点前面

{

chainList*s;

s=q->next;

q->next=s->next;

s->next=p->next;

p->next=s;

p=s;

break;

}

if(i==0)//年龄相同的插到后面

{

chainList*;

=q->next;

q->next=->next;

p=p->next;//让p永远指向插入位置前一个位置。

->next=p->next;

p->next=;

p=;

break;

}

p=p->next;

}

p=list;//让p重新指向头节点。

if(q->next)

q=q->next;//q前进一步。

} } void orderListBySex(chainList *list)//按性别排序,插入排序 { chainList*p,*q;p=q=list;

while(q->next){

if(q->next->pl->sex=='f')

{

chainList*s;

s=q->next;

q->next=s->next;//删除,然后插到前面

s->next=p->next;

p->next=s;

p=s;

}

q=q->next;} }

void printStaticInfo(chainList*list){ int count,countS,countT,countE,countMale,countFemale;count=countS=countT=countE=countMale=countFemale=0;chainList*p=list->next;while(p){

p->pl->print();

count++;

if(p->pl->sex=='m')

countMale++;

else

countFemale++;

switch(p->typeOfPn)

{

case 1:

countS++;

break;

} case 2:

countT++;

break;case 3:

countE++;

break;} p=p->next;

} cout

部分截图

1.信息的输入

2.浏览学生信息

开始N开始YNY输出所有信息返回主菜单录入信息保存信息返回主菜单打开文件文件中有无信息结束3.按姓名或学号查询信息

4.删除信息

开始NY输入姓名或学号开始NY输入姓名或学号N

打开文件打开文件Y输出信息(name==sign)||(number==sign))Y删除信息(name==sign)||(number==sign))N返回主菜单返回主菜单

心得体会:

通过本次课程设计懂得了,学习计算机语言知识,要不断实践,不断学习新的内容,特别是课堂中没有涉及的内容要自主的去学习并学会运用。在今后的学习中我要加强自主学习的能力,加强动手能力。通过一星期的C++语言程序设计课程设计,我们从中受益匪浅,并且对C++语言程序设计这一门课程有了更深一步的认识。在实习中,我们可以把这学期所学的理论知识和实践联系起来,在所要开发的项目中渐渐成长。虽然我们对这些C++语言知识运用得还不是很熟练,但是相信我们也在滴水穿石地成长起来。发现问题,提出问题,解决问题使我们从不足之处出发,寻找新的方向。在课程设计中,我设计了一个学生信息管理系统,它基本足了界面友好,易于操作的要求,因此更利于用户操作方便,运行简易,从而达到对人员管理更加有效系统的管理,并且速度更快内容更直接地达到用户所想要的效果。在该软件中我们实现了对学生信息的输入和存取、读取,对学生相关信息的删除等,并且可以按学号查询学生的相关信息等的功能。但软件中仍然存在一些不足,例如在输入有关学生的数据时名字没有限定,插入新的学生信息的程序还有待完善,菜单不美观等。我一边设计一边探索,发现理论和实践要充分地结合,是需要扎实的基本功的,这就表明学好基础知识是理论付诸实践的前提。在实习中我们学到了很多,希望在以后我们能充分利用这样的机会充实自己,并希望这样的机会能被更好更多地提供。

《c++学校人员信息管理系统.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
c++学校人员信息管理系统
点击下载文档
相关专题 学校人员信息管理系统 学校 信息管理系统 人员 学校人员信息管理系统 学校 信息管理系统 人员
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文