#includeiostream#includestring#includefstreamusingnamespacestd;classzhigong{public:voidsetnumber(intn){number=n;}voidsetname(char*na){strcpy(name,na);}voidsetbumen(char*bu){strcpy(bumen,bu);}intgetnumber(){returnnumber;}char*getname(){returnname;}char*getbumen(){returnbumen;}voidsetzhigong(){cout请输入职工所在部门:;cinbumen;cout请输入职工编号:;cinnumber;cout请输入职工姓名:;cinname;}private:intnumber;charname[20];charbumen[20];};classgongzi{public:voidsetgangwei(doubleg){gangwei=g;}voidsetjintie(doublej){jintie=j;}voidsetyiliao(doubley){yiliao=y;}voidsetshuidian(doubles){shuidian=s;}doublegetgangwei(){returngangwei;}doublegetjintie(){returnjintie;}doublegetyilao(){returnyiliao;}doublegetshuidian(){returnshuidian;}doublegetyingfa(){return(gangwei+jintie);}doublegetshifa(){return(gangwei+jintie-shuidian-yiliao);}voidsetgongzi(){cout请输入所得岗位工资:;cingangwei;cout请输入所得岗位津贴:;cinjintie;cout请输入所需缴纳的水电费:;cinshuidian;cout请输入所需要交纳的医疗保险费:;cinyiliao;}private:doublegangwei;doublejintie;doubleyiliao;doubleshuidian;};classzhigongzi:publiczhigong,publicgongzi{public:voidsetzhigongzi(){setzhigong();setgongzi();}};voidmenu(){cout***********************************************************************endl;cout--------------------------职工工资管理系统(小蛇制作)-----------------------------endl;cout***********************************************************************endl;cout**1.输入职工信息**endl;cout**2.修改职工工资**endl;cout**3.添加职工信息**endl;cout**4.删除职工信息**endl;cout**5.查询职工工资**endl;cout**6.显示职工信息**endl;cout**7.退出系统**endl;cout***********************************************************************endl;}inti=-1;intshuru(zhigongziz[]){ofstreamofile(D:\\zhigong.dat,ios::binary);if(!ofile){cout文件夹不能打开.endl;return0;}while(1){intp=1;while(p==1){i++;z[i].setzhigongzi();ofile.write((char*)&z[i],sizeof(zhigongzi));cout输入成功!endl;cout继续输入请按1,退出请按0:;cinp;}returni+1;}ofile.close();}intt,number;doublegangwei;doublejintie;doubleyiliao;doubleshuidian;charname[20];intxiugai(zhigongziz[],intm){ofstreamofile(D:\\zhigong.dat,ios::binary);intflag;intn=1;while(n==1){cout请输入要修改信息的职工号:;cinnumber;flag=0;inta;for(inti=0;im;i++)if(number==z[i].getnumber())do{cout请选择要修改的信息:endl;cout***********************************************endl;cout******1.修改岗位工资******endl;cout******2.修改岗位津贴******endl;cout******3.修改应交纳水电费******endl;cout******4.修改应交纳医疗保险费用******endl;cout***********************************************endl;cout请选择对应数字序号进行操作:;cina;if(a==1){cout请输入新的岗位工资:;cingangwei;z[i].setgangwei(gangwei);}if(a==2){cout请输入新的岗位津贴:;cinjintie;z[i].setjintie(jintie);}if(a==3){cout请输入新的水电费:;cinshuidian;z[i].setshuidian(shuidian);}if(a==4){cout请输入新的医疗保险费用:;cinyiliao;z[i].setyiliao(yiliao);}ofile.write((char*)&z[i],sizeof(zhigongzi));flag=1;}while(a1||a4);if(flag==0){cout查询不到该工号的职工,按0退出endl;cinn;}else{cout继续修改请按1/退出请按0:;cinn;}}coutendl;ofile.close();return0;}inttianjia(zhigongziz[],intm){intn=1;while(n==1){cout请输入要添加的新职工信息endl;z[t].setzhigongzi();cout添加成功!;t++;cout是否继续添加,继续请按1/退出请按0:endl;cinn;}returnt;}voidshanchu(zhigongziz[],intm){intflag;intn=1;while(n==1){cout请输入要删除的职工的职工号:;cinnumber;flag=0;for(inti=0;it;i++)if(number==z[i].getnumber()){intk;k=i;for(k;kt;k++){z[k]=z[k+1];t=t-1;}flag=1;cout*****删除成功*****endl;}if(flag==0){cout查询不到该工号的职工,无法删除按0退出endl;cinn;}else{cout继续删除请按1/退出请按0:;cinn;}}}voidchaxun(zhigongziz[],intm){cout-----------------[1]按姓名查询-------------------endl;cout-----------------[2]按工号查询-------------------endl;cout---请选择查询的方式(输入对应方式的序号1或2)---:;intk;cink;if(k==1){intu[10];intn=1;while(n==1){cout请输入要查询的职工的姓名:;cinname;intj=0;for(inti=0;it;i++)if(strcmp(name,z[i].getname())==0){u[j]=i;j++;}if(j==0){cout没有你要查询的职工名字endl;cout是否继续查询,继续请按1/退出按0:endl;cinn;}for(intb=0;bj;b++){if(j2){i=u[b];cout职工号姓名所属部门岗位工资岗位津贴水电费医疗保险应发工资实发工资endl;coutz[i].getnumber()\tz[i].getname()\tz[i].getbumen()\tz[i].getgangwei()\tz[i].getjintie()\tz[i].getshuidian()\tz[i].getyilao()\tz[i].getyingfa()\tz[i].getshifa()endl;}elsei=u[b];}}}if(k==2){intflag;intn=1;while(n==1){cout请输入要查询的职工的职工号:;cinnumber;flag=0;for(inti=0;it;i++)if(number==z[i].getnumber()){cout职工号姓名所属部门岗位工资岗位津贴水电费医疗保险应发工资实发工资endl;coutz[i].getnumber()\tz[i].getname()\tz[i].getbumen()\tz[i].getgangwei()\tz[i].getjintie()\tz[i].getshuidian()\tz[i].getyilao()\tz[i].getyingfa()\tz[i].getshifa()endl;flag=1;}if(flag==0){cout查询不到,按0退出endl;cinn;}else{cout是否继续查询,继续请按1/退出按0:endl;cinn;}}}}intxianshi(zhigongziz[],intm){cout职工工资信息:endl;cout职工号姓名所属部门岗位工资岗位津贴水电费医疗保险应发工资实发工资endl;for(inti=0;im;i++){coutz[i].getnumber()\tz[i].getname()\tz[i].getbumen()\tz[i].getgangwei()\tz[i].getjintie()\tz[i].getshuidian()\tz[i].getyilao()\tz[i].getyingfa()\tz[i].getshifa()