#include<iostream>#include<string>#include<fstream>powered by #include<iomanip>using namespace std;class employee{protected:int number;char name[20];char sex[6];char workplace[20];char place[20];char nation[6];char birth[20];char party[10];char id[20];float score[5];public:Employee *nest;Employee(){}~Employee(){}char* getname(){ return name; }int getnumber(){ return number; }double getscore(int i){ return score[i];}float get(){ return(score[0]+ score[1]+ score[2]+ score[3]+ score[4]);} void input(){int e=1;cout<<“\t\t\t按提示输入 :”<<endl ;cout<<“\t\t输入工号 :”;cin>>workplace ;do{cout<< “\t\t输入性别 :” ;cin>>sex ;if(strcmp(sex,“man”)==0 || strcmp(sex,“woman”)==0){cout<<“\t\t输入籍贯:”;cin >>place;cout<<“\t\t输入民族:”;cin >>nation;cout<<“\t\t输入生日:”;cin >>birth;cout<<“\t\t输入政治面貌:”;cin >>party;cout<<“\t\t输入身份证号:”;cin >>id;cout<<“\t\t输入工作时间:”;cin >>score[0];cout<<“\t\t输入缺勤次数:”;cin >>score[1];cout<<“\t\t输入业绩总评成绩:”;cin >>score[2];cout<<“\t\t输入跳动工作次数:”;cin >>score[3];cout<<“\t\t输入目前工资:”;cin >>score[4];e=0;}else{cout<<“\t\t\t无此类型性别!重新输入!”<<endl ;e=1 ;}}while(e) ;return ;}void input(ifstream & is){is>>number>>name>>sex>>place>>nation>>birth>>party>>id >>score[0]>> score[1]>> score[2]>> score[3]>> score[4]; is.get();}void output(){cout<<“职工基本信息如下:”<<endl;cout<<“工号:”<<number<<“姓名:”<<name<<“性别:”<<sex<<“籍贯:”<<place<<“民族:”<<nation<<“工作单位:”<<workplace<<“生日:”<<birth<<“政治面貌:”<<party<<endl<<“身份证号:”<<id<<“工作时间:”<<score[0]<<“缺勤次数:”<< score[1]<<“业绩总评成绩:”<<score[2]<<“调动工作次数:”<<score[3]<<“目前工资:”<<score[4]<<endl;}void output(ofstream & os){os<<setw(6)<<number<<setw(15)<<name<<setw(6)<<sex<<setw(20)<<place<<setw(6)<<nation<<setw(20)<<workplace<<setw(20)<<birth<<setw(20)<<party<<setw(20)<<id<<setw(6)<<score[0]<<setw(6)<< score[1]<<setw(6)<< score[2]<<setw(6)<< score[3]<<setw(6)<< score[4]<<endl;}};class company{Public:company(){head=new Employee;head->next=NULL;key=0;} ~company(){delete head;}void input();void mend();void del();int find(Employee**p,int num,char *pn=“^”) ;void found();void show();void save();void begin();void clear;char mainmenu();int getkey(){return key;}void setkey(int k)(key=k;)Employee *head;int key;};Void company::input(){Employee *p,*p2=NULL;P=head;int n;while(p->next)p=p->next;while(n){p2=new Employee;p2->input();p->next=p2;p2->next=NULL;p=p->next;company::setkey(1);cout<<”\t\t\t按1继续,按0返回:”;cin>>n;}}int company::find(Employee **p1,int num,char *pn){Employee *p;p=head;while(p->next){(*p1)=p;if((p->next)->getnumber()==num!strcmp((p->next)->getname(),pn)) return 1;p=p->next;}return 0;}void company::found(){Employee *p;int num=-1,n=9;char name[20]=”^”;{cout<<”\t\t1:按工号查找,2:按姓名查找:”;cin>>n;}while(n<1||n>2);if(n==1){cout<<”\t\t\t输入工号:”;cin>>num;}if(n==2){cout<<”\t\t\t输入姓名:”;cin>>name;}if(!find(&p,num,name)){cout<<”\t\t找不到你要查找的内容!”<<endl;return;}(p->next)->output();}V oid company::del(){Employee *p,*p2;int num;cout<<”\t\t\t输入工号:”;cin>>num;if(!find(&p,num,”^”)){cout<<”\t\t找不到你要删除的内容!”<<endl;return;}(p->next)->output();p2=p->next;p->next=p2->next;delete p2;company::setkey(1);}void company::show(){Employee::*p;p=head;while(p->next){(p->next)->output();p=p->next;}}void company::mend(){Employee *p;int num=-1,n;char name[20]=”^”;do{cout<<”\t\t1:按工号修改,2:按姓名修改:”;cin>>n;}while(n<1||n>2);if(n==1){cout<<”\t\t\t输入工号:”;cin>>num;}if(n==2){cout<<”\t\t\t输入姓名:”;cin>>num;}if(!find(&p,num,name)){cout<<”\t\t找不到你要修改的内容!”<<endl;return;}(p->next)->output();(p->next)->input();Company::setkey(1);}void company::save(){Employee *p;p=head;ofstream os(“Employee.txt”,ios::out);if(company::getkey()==1){while(p->next){(p->next)->output(os);p=p->next;}}cout<<”\t\t\t文件已保存!”<<endl ;company ::setkey(0) ;}void company ::begin(){Employee *p,*p2 ;p=head;clear();long t;ifstream is(“Employee.txt”,ios::in);if(!is){ofstream os(”Employee.txt”,ios::out);os.close();return;}int num=-1;while(1){num=-1;t=is.tellg();is>>num;is.seekg(t);if(num<0){is.close();return;}p2=new Employee;p2->input(is);p2->next=p2;p2->next=NULL;p=p->next;}}void company::clear(){Employee *p,*p2;P=head->next;while(p){p2=p;p=p->next;delete p2;}}char company::mainmenu(){char n[6];cout<<”\n\n ☆☆☆☆欢迎进入内蒙古医院人事管理系统☆☆☆☆”<<endl<<endl <<”****************************”<<endl<<”****************************”<<endl<<”** 1: 录入职工信息**”<<endl<<”** 2: 显示职工信息**”<<endl<<”** 3: 查找职工信息**”<<endl<<”** 4: 删除职工信息**”<<endl<<”** 5: 修改职工信息**”<<endl<<”** 6: 保存职工信息**”<<endl<<”** 0: 退出系统**”<<endl<<”****************************”<<endl<<”****************************”<<endl<<“请选择:”;cin>n;return n[0];}void main(){company pp;int k=1;char n;pp.begin();while(k==1){n=pp.mainmenu();switch(n){case’1’:pp.input();break;case’2’:pp.show();break;case’3’:pp.found();break;case’4’:pp.del();break;case’5’:pp.mend();break;case’6’:pp.save();break;case’0’:if(pp.getkey()==1){cout<<”\t\t\t是否保存?1:保存0:不保存:”;cin>.k;if(k==1)pp.save();}pp.clear();k=0;break;}}}。