c++学校人员信息管理系统_第1页
c++学校人员信息管理系统_第2页
c++学校人员信息管理系统_第3页
c++学校人员信息管理系统_第4页
c++学校人员信息管理系统_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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

2、teacher.h#includeempoyee.h#includechainList.h#includevoid 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);/根据名字删

3、除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);

4、void printList(chainList *list);int main()couttYou are welcome to the management system!endl;coutDo you want to load a file or setup a new list?Press l or s.sn;char fileName30;chainList headNode(0,NULL);chainList *head=&headNode;if(sn=l)ifstream file;coutFiles name:fileName;file.open(fileName);if(!

5、file)/为何输入不存在地文件后,机子变得很慢,而且没有结果出来?coutFile not found!System exit.endl;return 1;/couttestendl;/竟然通过!file的检查?(文件不存在阿)fileRead(head,file);/读入文件到链表file.close();printStaticInfo(head);char ctn;docoutmain menu:endl;coutt1.Add a person. 2.Delete a person3.Edit a personendl;coutt4.Search a person 5.Order the

6、 list6.Print info about the listendl;coutt0.exitctn;switch(ctn)case 0:break;case 1:addList(head);break;case 2:coutPlease input the persons name to be deleted:nm;chainList *pdel;pdel=searchList(head,nm);char sure;/Make sure whether you want to delete the datasure=n;if(!pdel-next)coutThe person you in

7、put cannt be foundendl;elsecoutThe persons infor follows:next-pl-print();coutAre you sure to delete it?Press y or nsure;if(sure=y)deleteNode(pdel);coutnm have been deleted!endl;break;case 3:coutPlease input the persons name:nm1;chainList *pp;pp=searchList(head,nm1);if(pp-next)coutThe persons infor f

8、ollows:next-pl-print();coutNow ,please edit the infors.endl;editList(head,nm1);elsecoutThe person cant be found !endl;break;case 4:coutPlease input the persons name:name;chainList *p;p=searchList(head,name);if(p-next)p-next-pl-print();elsecoutThe person cant be found!endl;break;case 5:coutYou want t

9、o order the list by:endl; 2.age 3.sex(lady first)ch;switch(ch)case 1:coutYou choose to order the list by name.The result are as follows:endl;orderList(head);printStaticInfo(head);break;case 2:coutYou choose to order the list by age.The result are as follows:endl;orderListByAge(head);printS

10、taticInfo(head);break;case 3:coutYou choose to order the list by sex.The result are as follows:endl;orderListBySex(head);printStaticInfo(head);break;default:coutWrong choice!endl;break;case 6:printStaticInfo(head);break;default:coutWrong choice!endl;while(ctn!=0);coutDo you want to save the file?No,

11、press n.Else,any other key.save;if(save!=n)coutPlease input the files name:fileName;ofstream fin;fin.open(fileName);/如果文件已经存在,询问是否覆盖。如何知道是否存在if(!fin)coutCant open output file.n;return 1;fileWrite(head,fin);fin.close();coutFile has been successfully saved!endl;coutByebye!tp;while(tp)ffag;ffnm;ffsx;sw

12、itch(tp)case 1:ffgrd;ffschl;psn=new student(ag,nm,sx,grd,schl,e,m,g,average);break;case 2:ffsb;ffteaYear;psn=new teacher(ag,nm,sx,sb,teaYear);break;case 3:ffslr;psn=new empoyee(ag,nm,sx,slr);break;chainList*s=new chainList(tp,psn);p-next=s;p=s;fftp;void fileWrite(chainList *list,ofstream &ff)chainLi

13、st*p=list-next;while(p)fftypeOfPn pl-age pl-name pl-sextypeOfPn)case 1:ffpl)-grade pl)-schoolendl;break;case 2:ffpl)-subject pl)-yearsOfTendl;break;case 3:ffpl)-salarynext;int aa=0;ffp2i)return 1;elsereturn -1;void addList(chainList *list)/添加节点char tp;int type;docoutThe person whose info you want to

14、 input is:endl;cout1.a student 2.a teacher3.a common employeeendl;cout0.Return to main menu.tp;/为什么一输入字符就死循环?char nm20;int ag;char sx;int slr;int grd;char schl20; int e;int m; int g;int average;char sb20;int teaYear;int aa=1;persons*psn;/插入人员指针switch(tp)case 0:aa=0;type=0;break;case 1:type=1;coutnam

15、e:nm;coutage:ag;coutmale or female?m or f?sx;coutThe students gradegrd;coutFrom which school:schl;coutthe score of english:e;coutthe score of math:m;coutthe score of sjjg:g; coutaverage:averageendl;psn=new student(ag,nm,sx,grd,schl,e,m,g,average);break;case 2:type=2;coutname:nm;coutage:ag;coutmale o

16、r female?m or f?sx;coutsubject field:sb;coutYears as a teacher:teaYear;psn=new teacher(ag,nm,sx,sb,teaYear);break;case 3:type=3;coutname:nm;coutage:ag;coutmale or female?m or f?sx;coutThe employees salary:slr;psn=new empoyee(ag,nm,sx,slr);break;default:type=6;aa=0;coutWrong choice!next)com=compareSt

17、r(nm,p-next-pl-name);coutcomnext&com0)/比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,ch

18、ar *name)/删除,添加就是编辑。缺点:不想删除的也被删除了。chainList *pde;pde=searchList(list,name);char tp;int type;docoutThe person whose info you want to input is:endl;cout1.a student 2.a teacher3.a common employeeendl;cout0.Return to main menu.tp;/为什么一输入字符就死循环?char nm20;int ag;char sx;int slr;int grd;char schl20;int e;

19、int m; int g;int average;char sb20;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;coutname:nm;coutage:ag;coutmale or female?m or f?sx;coutThe students gradegrd;coutFrom which school:schl;coutthe score of english:e;coutthe sc

20、ore of math:m;coutthe score of sjjg:g;psn=new student(ag,nm,sx,grd,schl,e,m,g,average);break;case 2:type=2;coutname:nm;coutage:ag;coutmale or female?m or f?sx;coutsubject field:sb;coutYears as a teacher:teaYear;psn=new teacher(ag,nm,sx,sb,teaYear);break;case 3:type=3;coutname:nm;coutage:ag;coutmale

21、or female?m or f?sx;coutThe employees salary:slr;psn=new empoyee(ag,nm,sx,slr);break;default:type=6;aa=0;coutWrong choice!next)com=compareStr(nm,p-next-pl-name);coutcomnext&com0)/比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-nex

22、t=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值(即名字相同)或者pnext为空退出p=p-next;if(p-next)com=compareStr(name,p-next-pl-name);return p;void orderList(chainList *list)chainList *p,*q;p=list

23、;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(i0)/字母顺序小的插在前面chainList*s;s=q-next;q-next=s-next;s-next=p-next;p-next=s;p=s;break;if(i=0)/字母顺序相同的插到后面chainList*ss;ss=q-next;q-next=ss-next;p=p-next;/让p永远指向插入位置前一个位置。ss-next=p-nex

24、t;p-next=ss;p=ss;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(i0)/年龄大的插到用于比较的节点前面chainList*s;s=q-next;q-next=s-next;s-next=p-next;p-ne

25、xt=s;p=s;break;if(i=0)/年龄相同的插到后面chainList*ss;ss=q-next;q-next=ss-next;p=p-next;/让p永远指向插入位置前一个位置。ss-next=p-next;p-next=ss;p=ss;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;

26、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+;elsecountFemale+;switch(p-typeOfPn)case 1:countS+;break;case 2:countT+;break;case 3:countE+;break;p=p-next;cout*endl;coutHere are the infors in the

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论