c++学校人员信息管理系统.docx
- 文档编号:11045612
- 上传时间:2023-02-24
- 格式:DOCX
- 页数:30
- 大小:143.30KB
c++学校人员信息管理系统.docx
《c++学校人员信息管理系统.docx》由会员分享,可在线阅读,更多相关《c++学校人员信息管理系统.docx(30页珍藏版)》请在冰豆网上搜索。
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〈stdio、h〉 void(chainList*list,ifstream&ff);//把文件从硬盘上读入内存 void(chainList*list,ofstream&ff);//写入硬盘 intpareStr(char*str1,char*str2);//名字作为关键字,这个函数就用来比较 voidaddList(chainList*list);//同名得话,覆盖,或者改为新名字加入 voiddeleteNode(chainList*node);//根据名字删除 voideditList(chainList*list,char*name);//要编辑得人名与新得资料 chainList *searchList(chainList*list,char*name);//只提供名字查询(其她以后加入) //返回前一个节点得指针 voidorderList(chainList*list);//按名字排序 void orderListByAge(chainList*list);//按年龄降序排列 void orderListBySex(chainList *list);//按照性别排列,女士优先 voidprintStaticInfo(chainList*list); void printList(chainList*list); intmain() {cout〈<”\tYou areweleto themanagementsystem! "< ﻩcout<〈"Doyouwanttoloada setupanew list? Press lors、"<<endl; ﻩcharsn; ﻩcin>>sn; ﻩchar[30]; chainListheadNode(0,NULL); ﻩchainList *head=&headNode; if(sn==’l') {ifstreamfile; cout〈〈"File’sname: "< ﻩﻩcin〉>; (); ﻩif(! 为何输入不存在地文件后,机子变得很慢,而且没有结果出来? ﻩﻩ{cout〈<” found! Systemexit、"<〈endl; ﻩreturn1; ﻩﻩ} //ﻩcout<<"test"〈〈endl;//竟然通过! file得检查? (文件不存在阿) ﻩ(head,读入文件到链表 (); } ﻩprintStaticInfo(head); ﻩcharctn; ﻩdo {cout<<”mainmenu: "〈〈endl; ﻩcout<<”\t1、Addaperson、2、Deletea personﻩ3、Editaperson"< ﻩﻩcout<<"\t4、Search a person5、Orderthelistﻩ6、Print info aboutthelist”〈<endl; cout〈〈"\t0、exit"< cin>>ctn; ﻩswitch(ctn) ﻩﻩ{ ﻩcase’0’: break; ﻩcase '1’: addList(head); ﻩbreak; case'2': ﻩcout〈〈"Pleaseinput theperson's nametobedeleted: ”< ﻩchar nm[20]; ﻩﻩcin〉>nm; ﻩchainList*pdel; ﻩﻩpdel=searchList(head,nm); char sure;//Makesure whether youwanttodeletethe data ﻩsure=’n'; ﻩﻩﻩif(! pdel—〉next) ﻩ{ cout<〈"The person youinputcann'tbefound”<<endl; ﻩﻩﻩ} ﻩﻩelse{ ﻩcout<〈”Thepersonsinforfollows: "〈<endl; ﻩﻩﻩﻩpdel-〉next->pl—>print(); ﻩﻩﻩcout〈<"Areyousure to deleteit? Pressyorn"< ﻩcin〉>sure; ﻩﻩif(sure=='y') ﻩ{ ﻩdeleteNode(pdel); ﻩﻩcout〈〈nm<〈” havebeendeleted! ”< ﻩ} ﻩﻩ} ﻩﻩbreak; ﻩﻩcase '3’: ﻩcout<<"Pleaseinputtheperson'sname: "<<endl; charnm1[20]; cin〉>nm1; ﻩﻩchainList *pp; ﻩpp=searchList(head,nm1); ﻩif(pp->next) ﻩ{ ﻩﻩcout〈〈”The person’sinfor follows: "〈 ﻩﻩﻩﻩpp—〉next->pl—〉print(); ﻩﻩcout〈<"Now,pleaseedittheinfors、”<〈endl; ﻩﻩﻩeditList(head,nm1); ﻩﻩ} ﻩelse ﻩﻩﻩcout<<”Thepersoncan’tbefound ! ! "<〈endl; break; case'4': ﻩﻩﻩcout<<"Please input theperson'sname: "<<endl; ﻩﻩcharname[30]; ﻩﻩcin〉>name; chainList *p; ﻩp=searchList(head,name); ﻩﻩﻩif(p->next) { ﻩp->next->pl—〉print(); ﻩ} ﻩelse ﻩﻩcout<〈"Theperson can't befound! "<〈endl; ﻩﻩﻩbreak; case '5': ﻩﻩcout<〈"Youwantto orderthe list by: ”〈<endl; ﻩﻩcout<〈”1、name2、age 3、sex(ladyfirst)"<〈endl; ﻩchar ch; ﻩﻩcin〉>ch; ﻩﻩﻩswitch(ch) { ﻩﻩcase’1’: ﻩﻩcout〈<"Youchooseto orderthelistbyname、The resultareas follows: ”<<endl; ﻩorderList(head); ﻩﻩprintStaticInfo(head); ﻩﻩﻩbreak; case'2’: ﻩﻩcout〈〈"Youchoosetoorderthelist by age、Theresult areasfollows: ”〈〈endl; orderListByAge(head); ﻩprintStaticInfo(head); ﻩﻩbreak; case'3’: ﻩcout<<"Youchoosetoorderthelistbysex、Theresultareasfollows: "〈<endl; ﻩﻩﻩorderListBySex(head); ﻩﻩﻩprintStaticInfo(head); ﻩﻩbreak; ﻩdefault: ﻩﻩﻩcout<<"Wrongchoice! ”<<endl; ﻩﻩﻩ} ﻩbreak; ﻩcase’6': ﻩprintStaticInfo(head); break; ﻩdefault: ﻩﻩﻩcout<<"Wrong choice! ”<〈endl; ﻩ} }while(ctn! ='0’); cout〈〈"Doyouwanttosave then、Else,any otherkey、"<〈endl; charsave; cin〉>save; ﻩif(save! =’n') { cout〈<"Pleaseinput thefile’sname: ”<〈endl; ﻩcin>〉; ﻩﻩofstreamfin; fin、open();//如果文件已经存在,询问就是否覆盖。 如何知道就是否存在 ﻩif(! fin) ﻩ{ ﻩﻩcout<〈"Can'topenoutputfile、\n"; ﻩreturn1; } (head,fin); ﻩfin、close(); ﻩﻩcout<<"beensuccessfullysaved! ”< ﻩ} ﻩcout<<"Byebye! ”<<endl; return0; } void(chainList*list,ifstream &ff) { ﻩchainList*p=list; ﻩinttp; char nm[20]; intag; ﻩchar sx; int slr; ﻩint grd; inte; ﻩﻩintm; ﻩint g; ﻩintaverage; ﻩﻩcharschl[20]; char sb[20]; ﻩintteaYear; intaa=1; persons*psn;//插入人员指针 ﻩff〉>tp; while(tp) ﻩ{ﻩff>〉ag; ﻩﻩff〉>nm; ﻩﻩff>>sx; ﻩﻩswitch(tp) { ﻩﻩcase 1: ﻩff>>grd; ﻩﻩff〉>schl; ﻩﻩﻩpsn=newstudent(ag,nm,sx,grd,schl,e,m,g,average); ﻩbreak; case2: ﻩff>〉sb; ﻩff>>teaYear; ﻩﻩpsn=newteacher(ag,nm,sx,sb,teaYear); ﻩﻩbreak; ﻩﻩcase3: ff>〉slr; ﻩﻩﻩpsn=newempoyee(ag,nm,sx,slr); ﻩﻩbreak; ﻩ} ﻩﻩchainList*s=newchainList(tp,psn); ﻩﻩp->next=s; ﻩﻩp=s; ﻩﻩﻩff〉>tp; ﻩ} } void (chainList *list,ofstream&ff) { ﻩchainList*p=list->next; while(p) ﻩ{ ﻩff<〈p->typeOfPn〈<""〈 ﻩﻩswitch(p->typeOfPn) ﻩ{ ﻩcase1: ﻩﻩﻩff<〈((student*)p—〉pl)->grade<<" ”<<((student*)p->pl)->school<〈endl; ﻩbreak; case2: ﻩﻩff〈〈((teacher*)p—>pl)-〉subject<<” "〈<((teacher*)p->pl)->yearsOfT〈<endl; ﻩbreak; ﻩcase3: ﻩﻩff<<((empoyee*)p-〉pl)->salary< ﻩbreak; } p=p->next; } int aa=0; ﻩff<<aa; } intpareStr(char*str1,char*str2)//比较字符串 { ﻩchar*p1=str1,*p2=str2; inti=0; while((p1[i]==p2[i])&&p1[i]&&p2[i]) ﻩi++; ﻩif(p1[i]==p2[i]) ﻩ{ ﻩreturn0; } else ﻩ{if(p1[i]〉p2[i]) ﻩﻩﻩreturn1; ﻩelse ﻩﻩreturn—1; }ﻩ } voidaddList(chainList *list)//添加节点 { ﻩchar tp; ﻩinttype; ﻩdo{ ﻩﻩcout<<"Theperson whoseinfoyouwanttoinputis: "〈〈endl; cout〈<”1、a student 2、ateacherﻩ3、a monemployee”〈〈endl; ﻩcout<<”0、Returntomain menu、”<<endl; cin>>tp;//为什么一输入字符就死循环? ? ﻩcharnm[20]; ﻩint ag; ﻩﻩchar sx; ﻩintslr; intgrd; ﻩcharschl[20]; int e; ﻩintm; int g; intaverage; ﻩcharsb[20]; ﻩintteaYear; ﻩﻩintaa=1; persons*psn;//插入人员指针 switch(tp) { ﻩcase’0’: aa=0; ﻩtype=0; ﻩﻩﻩbreak; case '1': ﻩtype=1; ﻩcout〈〈"name: "〈<endl; ﻩﻩcin>〉nm; cout<<"age: "<<endl; ﻩﻩﻩcin〉>ag; ﻩcout<〈"maleor female? m orf? ”<〈endl; cin>>sx; ﻩcout<〈”Thestudent’sgrade”〈 cin>>grd; ﻩcout<<”Fromwhichschool: ”<<endl; ﻩcin〉〉schl; ﻩcout〈〈”thescoreofenglish: ”< ﻩcin>>e; ﻩcout〈<"thescoreofmath: ”〈 cin〉〉m; ﻩﻩcout〈〈"thescoreofsjjg: "<〈endl; ﻩﻩﻩcin〉>g; cout〈<"average: ”〈<average<<endl; ﻩﻩpsn=new student(ag,nm,sx,grd,schl,e,m,g,average); ﻩbreak; ﻩcase'2': type=2; ﻩﻩcout〈<”name: "<〈endl; cin〉〉nm; ﻩﻩcout〈<"age: ”< ﻩﻩﻩcin>〉ag; cout<〈”male orfemale? morf? ”< ﻩﻩcin>〉sx; ﻩﻩcout<〈”subject field: "〈 cin〉〉sb; ﻩﻩﻩcout〈<”Yearsasateacher: ”<〈endl; ﻩcin>〉teaYear; ﻩﻩpsn=new teacher(ag,nm,sx,sb,teaYear); ﻩbreak; ﻩcase’3': type=3; ﻩﻩﻩcout〈〈"name: "〈 ﻩcin>〉nm; ﻩﻩcout<<”age: "< ﻩﻩﻩcin>>ag; ﻩﻩﻩcout<<”maleorfemale? morf? ”〈〈endl; ﻩcin〉>sx; ﻩcout〈<"Theemployee'ssalary: ”<〈endl; ﻩﻩcin>>slr; psn=new empoyee(ag,nm,sx,slr); ﻩbreak; default: type=6; ﻩaa=0; cout<<"Wrongchoice! "<〈endl; ﻩ} chainList*p=list;//新节点在p所指得节点之前插入, ﻩif(aa) { ﻩﻩint; ﻩﻩif(p—〉next) ﻩﻩ{ ﻩﻩ=pareStr(nm,p—>next->pl—>name); ﻩﻩcout<<〈<endl; ﻩﻩ} ﻩﻩwhile(p->next&&〉0)//比p节点小或者p为空退出 { ﻩﻩﻩp=p—>next; ﻩﻩif(p—>next) ﻩ=pareStr(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; } voideditList(chainList*list,char*name)//删除,添加就就是编辑.缺点: 不想删除得也被删除了。 { chainList*pde; pde=searchList(list,name); ﻩchartp; inttype; do{ ﻩﻩcout〈<"Thepersonwhoseinfo youwanttoinput is: "〈〈endl; ﻩﻩcout<〈"1、a student2、ateacher3、a monemployee”〈〈endl; ﻩcout〈〈”0、Returntomainmenu、"<〈endl; ﻩﻩcin>>tp;//为什么一输入字符就死循环? ? char nm[20]; ﻩﻩintag; ﻩchar sx; ﻩintslr; ﻩintgrd; ﻩchar schl[20]; ﻩinte; intm; int g; int average; ﻩchar sb[20]; ﻩﻩintteaYear; ﻩintaa=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<<"name: ”<<endl; ﻩﻩﻩcin>〉nm; ﻩﻩcout<<"age: ”<<endl; cin〉〉ag; ﻩﻩcout<〈"maleor female? mor f? "〈<endl; ﻩﻩcin>>sx; ﻩﻩcout<<"Thestudent'sgrade”<〈endl; ﻩcin>〉grd; ﻩcout〈<"From whichschool: "<<endl; ﻩﻩcin>>schl; ﻩﻩcout〈〈"thescoreof english: ”〈 ﻩﻩcin〉〉e; ﻩﻩcout<〈”thescoreofmath: "〈 ﻩcin>>m; ﻩcout<〈"the scoreofsjjg: ”〈〈endl; ﻩcin>〉g; ﻩﻩpsn=newstudent(ag,nm,sx,grd,schl,e,m,g,average); ﻩbreak; ﻩﻩcase'2': type=2; ﻩﻩcout<<"name: "〈<endl; ﻩcin>>nm; ﻩﻩcout<<”age: ”<<endl; ﻩcin>〉ag; ﻩcout〈〈"maleorfemale? morf? "<〈endl; ﻩﻩcin>>sx; ﻩﻩcout<〈”subjectfield: "< ﻩﻩcin>>sb; ﻩcout〈〈"Years as a teacher: "<〈endl; cin>〉teaYear; ﻩﻩpsn=new teacher(ag,nm,sx,sb,teaYear); ﻩﻩbreak; ﻩcase’3’: type=3; ﻩcout〈<”name: "<〈endl; ﻩcin>〉nm; ﻩﻩcout<<"age: "<〈endl; ﻩﻩcin>〉ag; ﻩﻩcout<〈”maleorfemale? morf? ”〈〈endl; ﻩcin>〉sx; ﻩcout<〈"Theemployee’ssalary: ”〈<endl; ﻩcin>>slr; ﻩﻩﻩpsn=newempoyee(ag,nm,sx,slr); break; default: type=6; ﻩﻩﻩaa=0; ﻩﻩcout<<"Wrongchoice! "<〈endl; } chainList*p=list;//新节点在p所指得节点之前插入, ﻩif(aa) ﻩ{ ﻩint; ﻩif(p—〉next) { ﻩﻩﻩ=pareStr(nm,p—〉next->pl-〉name); ﻩcout<<<<endl; } ﻩﻩwhile(p—〉next&&>0)//比p节点小或者p为空退出 ﻩﻩ{ ﻩp=p->next; ﻩﻩﻩif(p->next) ﻩ=pareStr(nm,p—〉next->pl—〉name); ﻩ} ﻩchainList *s=new cha
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- c+ 学校 人员 信息管理 系统