职工工资管理系统程序中新增临时员工的功能这个职工工资管理系统基本功能都十分完善,代码也都比较简洁,运行效率也很高,没有什么直接能改的功能,所以我基于现在许多大学生找兼职、临时工的现象,增添了临时员工的工资系统,可以方便公司、企业等更加完善公司的财务系统。也方便公司为临时员工发放工资。代码段一是原来的工资程序系统代码段二是增添临时员工后的工资系统代码一、
#include#includeusing namespace std;class Staff {protected:string number;string name;string sex;string address;int salary;static int sum_salary; //总工资static int sum_member; //总员工人数public:Staff();Staff(string number,string name,string sex,string address,int salary);void print() {};void setnumber(string num) {number=num;}void setname(string na) {name=na;}void setsex(string se) {sex=se;}void setaddress(string add) {address=add;}void setsalary(int sa) {salary=sa;}int getsalary();string getname() {return name;}string getnumber() {return number;}string getsex() {return sex;}string getaddress() {return address;}};Staff::Staff() {number="";name="";sex="";address="";salary=0;}Staff::Staff(string number,string name,string sex,string address,int salary) {this->number = number;this->name = name;this->sex = sex;this->address = address;this->salary = salary;}int Staff::getsalary() {return salary;}class Regular_staff:public Staff {protected:int allowance; //岗位津贴int old_age_pension; //养老金int Housing_Fund; //住房公积金int medical_insurance; //医疗保险int tax;int r_salary; //实际工资public:Regular_staff();Regular_staff(string num,string na,string sex,string add,int salary,int all ,int oap, int Hou, int med);void getr_salary();//计算实发工资void gettax();int getreal() {return r_salary;}void setallowance(int all) {allowance=all;}void setold_age_pension(int oap) {old_age_pension=oap;}void setHousing_Fund(int Hou) {Housing_Fund=Hou;}void setmedical_insurance(int med) {medical_insurance=med;}void display() {cout<<"员工编号:"<<number<<"\t"<<"姓名:"<<name<<"\t"<<"性别:"<<sex<<endl;cout<<"地址:"<<address<<endl;cout<<"岗位津贴:"<<allowance<<"\t"<<"养老金:"<<old_age_pension<<endl;cout<<"住房公积金:"<<Housing_Fund<<"\t"<<"医疗保险:"<<medical_insurance<<endl;cout<<"本月税后实际工资:"<<r_salary<salary = getsalary();if (salary5000&&r_salary41000&&r_salary149000&&r_salary305000&&r_salary425000&&r_salary665000&&r_salary965000) {tax=(salary-965000)*0.45+181920;}}Regular_staff::Regular_staff(string num,string na,string sex,string add,int salary,int all ,int oap, int Hou, int med) : Staff(num,na ,sex, add ,salary) {this->allowance = all;this->old_age_pension = oap;this->Housing_Fund = Hou;this->medical_insurance = med;gettax();r_salary = getsalary()+allowance-old_age_pension-Housing_Fund-medical_insurance-tax;}void Regular_staff::getr_salary() {r_salary = getsalary()+allowance-old_age_pension-Housing_Fund-medical_insurance-tax;}class Temporary_staff:public Staff {protected:int bonus; //奖金int tax;int r_salary; //实际工资public:Temporary_staff();Temporary_staff(string num,string na,string sex,string add,int salary,int bo );void gettax();int getr_salary();int getreal() {return r_salary;}void setbonus(int bo) {bonus=bo;}void display() {cout<<"员工编号:"<<number<<"\t"<<"姓名:"<<name<<"\t"<<"性别:"<<sex<<endl;cout<<"地址:"<<address<<endl;cout<<"奖金:"<<bonus<<endl;cout<<"本月税后实际工资:"<<r_salary<<endl;}int getbonus() {return bonus;}} ts[10000];Temporary_staff::Temporary_staff() {number="";name="";sex="";address="";salary=0;bonus=0;}void Temporary_staff::gettax() {if (salary5000&&salary41000&&salary149000&&salary305000&&salary425000&&salary665000&&salary965000) {tax=(salary-965000)*0.45+181920;}}Temporary_staff::Temporary_staff(string num,string na,string sex,string add,int salary,int bo ) : Staff(num ,na ,sex, add ,salary) {this->bonus = bo;gettax();r_salary =salary + bonus - tax;//计算最终工资}void print_Begin() {printf("\n\t\t 职工工资管理系统\n\n");printf("**************************************************\n\n");printf("1 查找员工信息\n\n2 更新员工数据\n\n3 输出员工信息\n\n4 关闭程序\n\n");printf("**************************************************\n\n");printf("请选择:");}void loading() {printf("\n\n\t\tLoading......\n\n\n");printf(" ");for (int i = 1; i >num>>na>>sex>>add>>salary>>all>>oap>>Hou>>med;rs[i].setnumber(num);rs[i].setname(na);rs[i].setsex(sex);rs[i].setaddress(add);rs[i].setsalary(salary);rs[i].setallowance(all);rs[i].setold_age_pension(oap);rs[i].setHousing_Fund(Hou);rs[i].setmedical_insurance(med);rs[i].gettax();rs[i].getr_salary();}x=i-1;f.close();}void find_name_r(string n) {//通过员工姓名,查询正式员工的数据get_rstxt();for(int i=0; i<=x; i++) {if(rs[i].getname()==n) {rs[i].display();cout<<endl;break;}if(i==x) {cout<<"抱歉,未查询到该员工,请核实员工信息!"<<endl;break;}}}void find_number_r(string m) {//通过编号查找员工get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==m) {rs[i].display();cout<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核实员工信息!"<<endl;break;}}}void find_salary_r(double a,double b) {//工资范围 ,控制 a <= b 员工int num=0;get_rstxt();for(int i=0; i=a&&rs[i].getreal()<=b) {rs[i].display();cout<<endl;num++;}if(i==x-1&&num==0) {cout<<"抱歉,未查询到相应员工,请核实员工信息!"<<endl;break;}}}void modify_new_r() { //新增员工信息string num;string na;string sex;string add;int salary;int all ;int oap;int Hou;int med;cout<>num>>na>>sex>>add>>salary>>all>>oap>>Hou>>med;get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==num) {cout<<"\n编号重复!请核实员工信息!";break;}if(i==x-1) {fstream f;f.open("Regular_staff.txt",ios::out|ios::app);f<<num<<" "<<na<<" "<<sex<<" "<<add<<" "<<salary<<" "<<all<<" "<<oap<<" "<<Hou<<" "<<med<<" ";f.close();cout<<"已将"<<na<<"加入系统名单!";}}}void modify_address_r(string num) { // 地址get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==num) {cout<<"已找到该员工,请输入该员工新的家庭住址;"<>new_address;rs[i].setaddress(new_address);cout<<"修改成功!!"<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核对员工信息!"<<endl;break;}}fstream fc("Regular_staff.txt",ios::trunc);fc.close();fstream f;f.open("Regular_staff.txt",ios::out);for(int i=0; i<x; i++) {f<<rs[i].getnumber()<<" "<<rs[i].getname()<<" "<<rs[i].getsex()<<" "<<rs[i].getaddress()<<" "<<rs[i].getsalary()<<" "<<rs[i].getallowance()<<" "<<rs[i].getold_age_pension()<<" "<<rs[i].getHousing_Fund()<<" "<<rs[i].getmedical_insurance()<<" ";}f.close();}void modify_salary_r(string num) { //修改工资 清屏 重新输入 get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==num) {cout<<"已找到该员工,请输入该员工新的基础工资;"<>new_salary;rs[i].setsalary(new_salary);cout<<"修改成功!!"<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核对员工信息!"<<endl;break;}}fstream fc("Regular_staff.txt",ios::trunc);fc.close();fstream f;f.open("Regular_staff.txt",ios::out);for(int i=0; i<x; i++) {f<<rs[i].getnumber()<<" "<<rs[i].getname()<<" "<<rs[i].getsex()<<" "<<rs[i].getaddress()<<" "<<rs[i].getsalary()<<" "<<rs[i].getallowance()<<" "<<rs[i].getold_age_pension()<<" "<<rs[i].getHousing_Fund()<<" "<<rs[i].getmedical_insurance()<<" ";}f.close();}void print_num_r() {//打印员工信息 get_rstxt();for(int i=0; i<x; i++) {cout<<endl<<"员工编号:"<<rs[i].getnumber()<<" 员工姓名:"<<rs[i].getname()<<endl<<endl;cout<<"员工地址:"<<rs[i].getaddress()<<endl<<endl;cout<<"员工性别:"<<rs[i].getsex()<<" 员工税后实际工资:"<<rs[i].getreal()<<endl<<endl;cout<<"--------------------------------------------------------------------"<<endl;}}void print_num(int type) {int i,j,o = type;get_rstxt();Regular_staff temp_r;Temporary_staff temp_t;cout<<"按编号由低到高输出:"<<endl<<"--------------------------------------------------------------------"<<endl;// cout<<"按编号顺序输出:1.员工 2."<<endl<<"请输入:"<>o;switch(o) {case 1:for (j=0; j<x; j++) {for (i=0; irs[i+1].getnumber()) {temp_r=rs[i];rs[i]=rs[i+1];rs[i+1]=temp_r;}}}print_num_r();break;}}void print_sequence(int type) {int i,j,o = type;get_rstxt();Regular_staff temp_r;Temporary_staff temp_t;cout<<"按工资由低到高输出:"<<endl<<"--------------------------------------------------------------------"<<endl;switch(o) {case 1:for (j=0; j<x; j++) {for (i=0; i<x-j; i++) {if (rs[i].getreal()<rs[i+1].getreal()) {temp_r=rs[i];rs[i]=rs[i+1];rs[i+1]=temp_r;}}}print_num_r();break;}}void print_flashback(int type) {int i,j,o = type;get_rstxt();Regular_staff temp_r;Temporary_staff temp_t;cout<<"按工资由低到高输出:"<<endl<<"--------------------------------------------------------------------"<<endl;switch(o) {case 1:for (j=0; j<x; j++) {for (i=0; irs[i+1].getreal()) {temp_r=rs[i];rs[i]=rs[i+1];rs[i+1]=temp_r;}}}print_num_r();break;}}int type=1;void print_opt1() {printf("\n\t\t 1 查找员工信息\n\n");printf("**************************************************\n\n");printf("1 职工姓名\n\n2 职工编号\n\n3 工资介于a到b的职工\n\n");printf("**************************************************\n\n");printf("请选择:");}void opt1() {string num1;while(1) {cls();print_opt1(); cin>>num1;if(num1 == "1") {cls();cout <<"请输入员工姓名:"<> n;cout<<endl;if(type == 1) {find_name_r(n);} break;}if (num1 == "2") {cls();cout <<"请输入员工编号:"<> n;cout<<endl;if(type == 1) {find_number_r(n);} }break;}if (num1 == "3") {cls();cout <<"请输入工资范围(最小值和最大值):"<> a >> b;cout<b) {double temp;temp = a;a = b;b = temp;}if(type == 1) {find_salary_r(a,b);} } else {printf("\n员工信息输入错误!x_x\n请重试!");Sleep(1500);}}void print_opt2() {printf("\n\t\t 2 更新员工数据\n\n");printf("**************************************************\n\n");printf("1 新增员工数据\n\n2 修改员工数据\n\n3 返回主界面\n\n");printf("**************************************************\n\n");printf("请选择:");}void opt2() {string num2;while(1) {cls();print_opt2();cin >> num2;if(num2=="1") {cls();cls();if(type == 1) {modify_new_r();}break; }if (num2 == "2") {cls();cls();printf("\n\n1 修改员工地址\n\n2 修改员工工资\n\n请选择:");int n;cin >> n;cls();string m;printf("\n\n请输入员工编号:");cin>>m;if(type ==1) {cls();if(n ==1) modify_address_r(m);if(n ==2) modify_salary_r(m);}break;}if(num2=="3") {cls();break;} else {cls();printf("\n输入错误!x_x\n\n请重试\n\n");Sleep(1500);continue;}}}void print_opt3() {printf("\n\t\t 3 输出员工信息\n\n");printf("**************************************************\n\n");printf("1 按工资由高到低输出 \n\n2 按工资由低到高输出\n\n3 按编号输出(低到高)\n\n4 返回主界面\n\n");printf("**************************************************\n\n");printf("请选择:");}void opt3() {string num3;while(1) {cls();print_opt3();cin >> num3;if(num3 == "1") {cls();cls();print_sequence(type);break;}if(num3 == "2") {cls();cls();print_flashback(type);break;}if(num3 == "3") {cls();cls();print_num(type);break;}if(num3 == "4") {cls();break;} else {cls();cout<<"请输入正确的选项!"<> opt;o=atoi(opt.c_str());switch(o) {case 1:opt1();system("pause");refresh();break;case 2:opt2();system("pause");refresh();break;case 3:opt3();system("pause");refresh();break;case 4:opt4();Sleep(500) ;return 0;default:cls();opt_error();system("pause");refresh();break;}}}
代码二、
#include#includeusing namespace std;class Staff {protected:string number;string name;string sex;string address;int salary;static int sum_salary; //总工资static int sum_member; //总员工人数public:Staff();Staff(string number,string name,string sex,string address,int salary);void print() {};void setnumber(string num) {number=num;}void setname(string na) {name=na;}void setsex(string se) {sex=se;}void setaddress(string add) {address=add;}void setsalary(int sa) {salary=sa;}int getsalary();string getname() {return name;}string getnumber() {return number;}string getsex() {return sex;}string getaddress() {return address;}};Staff::Staff() {number="";name="";sex="";address="";salary=0;}Staff::Staff(string number,string name,string sex,string address,int salary) {this->number = number;this->name = name;this->sex = sex;this->address = address;this->salary = salary;}int Staff::getsalary() {return salary;}class Regular_staff:public Staff {protected:int allowance; //岗位津贴int old_age_pension; //养老金int Housing_Fund; //住房公积金int medical_insurance; //医疗保险int tax;int r_salary; //实际工资public:Regular_staff();Regular_staff(string num,string na,string sex,string add,int salary,int all ,int oap, int Hou, int med);void getr_salary();//计算实发工资void gettax();int getreal() {return r_salary;}void setallowance(int all) {allowance=all;}void setold_age_pension(int oap) {old_age_pension=oap;}void setHousing_Fund(int Hou) {Housing_Fund=Hou;}void setmedical_insurance(int med) {medical_insurance=med;}void display() {cout<<"员工编号:"<<number<<"\t"<<"姓名:"<<name<<"\t"<<"性别:"<<sex<<endl;cout<<"地址:"<<address<<endl;cout<<"岗位津贴:"<<allowance<<"\t"<<"养老金:"<<old_age_pension<<endl;cout<<"住房公积金:"<<Housing_Fund<<"\t"<<"医疗保险:"<<medical_insurance<<endl;cout<<"本月税后实际工资:"<<r_salary<salary = getsalary();if (salary5000&&r_salary41000&&r_salary149000&&r_salary305000&&r_salary425000&&r_salary665000&&r_salary965000) {tax=(salary-965000)*0.45+181920;}}Regular_staff::Regular_staff(string num,string na,string sex,string add,int salary,int all ,int oap, int Hou, int med) : Staff(num,na ,sex, add ,salary) {this->allowance = all;this->old_age_pension = oap;this->Housing_Fund = Hou;this->medical_insurance = med;gettax();r_salary = getsalary()+allowance-old_age_pension-Housing_Fund-medical_insurance-tax;}void Regular_staff::getr_salary() {r_salary = getsalary()+allowance-old_age_pension-Housing_Fund-medical_insurance-tax;}class Temporary_staff:public Staff {protected:int bonus; //奖金int tax;int r_salary; //实际工资public:Temporary_staff();Temporary_staff(string num,string na,string sex,string add,int salary,int bo );void gettax();int getr_salary();int getreal() {return r_salary;}void setbonus(int bo) {bonus=bo;}void display() {cout<<"员工编号:"<<number<<"\t"<<"姓名:"<<name<<"\t"<<"性别:"<<sex<<endl;cout<<"地址:"<<address<<endl;cout<<"奖金:"<<bonus<<endl;cout<<"本月税后实际工资:"<<r_salary<<endl;}int getbonus() {return bonus;}} ts[10000];Temporary_staff::Temporary_staff() {number="";name="";sex="";address="";salary=0;bonus=0;}void Temporary_staff::gettax() {if (salary5000&&salary41000&&salary149000&&salary305000&&salary425000&&salary665000&&salary965000) {tax=(salary-965000)*0.45+181920;}}Temporary_staff::Temporary_staff(string num,string na,string sex,string add,int salary,int bo ) : Staff(num ,na ,sex, add ,salary) {this->bonus = bo;gettax();r_salary =salary + bonus - tax;//计算最终工资}void print_Begin() {printf("\n\t\t 职工工资管理系统\n\n");printf("**************************************************\n\n");printf("1 查找员工信息\n\n2 更新员工数据\n\n3 输出员工信息\n\n4 关闭程序\n\n");printf("**************************************************\n\n");printf("请选择:");}void loading() {printf("\n\n\t\tLoading......\n\n\n");printf(" ");for (int i = 1; i >num>>na>>sex>>add>>salary>>all>>oap>>Hou>>med;rs[i].setnumber(num);rs[i].setname(na);rs[i].setsex(sex);rs[i].setaddress(add);rs[i].setsalary(salary);rs[i].setallowance(all);rs[i].setold_age_pension(oap);rs[i].setHousing_Fund(Hou);rs[i].setmedical_insurance(med);rs[i].gettax();rs[i].getr_salary();}x=i-1;f.close();}void get_tstxt() {//读取临时员工的数据fstream f;f.open("Temporary_staff.txt",ios::in);string num;string na;string sex;string add;int salary;int bo;int i;for(i=0; f.eof(); i++) {f>>num>>na>>sex>>add>>salary>>bo;ts[i].setnumber(num);ts[i].setname(na);ts[i].setsex(sex);ts[i].setaddress(add);ts[i].setsalary(salary);ts[i].setbonus(bo);}x=i-1;f.close();}void find_name_r(string n) {//通过员工姓名,查询正式员工的数据get_rstxt();for(int i=0; i<=x; i++) {if(rs[i].getname()==n) {rs[i].display();cout<<endl;break;}if(i==x) {cout<<"抱歉,未查询到该员工,请核实员工信息!"<<endl;break;}}}void find_name_t(string n) {//通过员工姓名,查询临时员工的数据get_tstxt();for(int i=0; i<x; i++) {if(ts[i].getname()==n) {ts[i].display();cout<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核实员工信息!"<<endl;break;}}}void find_number_r(string m) {//通过编号查找 正式 员工get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==m) {rs[i].display();cout<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核实员工信息!"<<endl;break;}}}void find_number_t(string m) {//通过编号查找 临时 员工get_tstxt();for(int i=0; i<x; i++) {if(ts[i].getnumber()==m) {ts[i].display();cout<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核实员工信息!"<<endl;break;}}}void find_salary_r(double a,double b) {//工资范围 ,控制 a <= b 正式员工int num=0;get_rstxt();for(int i=0; i=a&&rs[i].getreal()<=b) {rs[i].display();cout<<endl;num++;}if(i==x-1&&num==0) {cout<<"抱歉,未查询到相应员工,请核实员工信息!"<<endl;break;}}}void find_salary_t(double a,double b) {//工资范围 , 同上int num=0;get_tstxt();for(int i=0; i=a&&ts[i].getreal()<=b) {ts[i].display();cout<<endl;num++;}if(i==x-1&&num==0) {cout<<"抱歉,未查询到相应员工,请核实员工信息!"<<endl;break;}}}void modify_new_r() { //新增员工信息string num;string na;string sex;string add;int salary;int all ;int oap;int Hou;int med;cout<>num>>na>>sex>>add>>salary>>all>>oap>>Hou>>med;get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==num) {cout<<"\n编号重复!请核实员工信息!";break;}if(i==x-1) {fstream f;f.open("Regular_staff.txt",ios::out|ios::app);f<<num<<" "<<na<<" "<<sex<<" "<<add<<" "<<salary<<" "<<all<<" "<<oap<<" "<<Hou<<" "<<med<<" ";f.close();cout<<"已将"<<na<<"加入系统名单!";}}}void modify_new_t() {string num;string na;string sex;string add;int salary;int bo;cout<>num>>na>>sex>>add>>salary>>bo;get_tstxt();for(int i=0; i<x; i++) {if(ts[i].getnumber()==num) {cout<<"\n编号重复!请核实员工信息!";break;}if(i==x-1) {fstream f;f.open("Temporary_staff.txt",ios::out|ios::app) ;f<<num<<" "<<na<<" "<<sex<<" "<<add<<" "<<salary<<" "<<bo<<" ";f.close();cout<<"已将"<<na<<"加入系统名单!";}}}void modify_address_r(string num) { //正式 地址get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==num) {cout<<"已找到该员工,请输入该员工新的家庭住址;"<>new_address;rs[i].setaddress(new_address);cout<<"修改成功!!"<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核对员工信息!"<<endl;break;}}fstream fc("Regular_staff.txt",ios::trunc);fc.close();fstream f;f.open("Regular_staff.txt",ios::out);for(int i=0; i<x; i++) {f<<rs[i].getnumber()<<" "<<rs[i].getname()<<" "<<rs[i].getsex()<<" "<<rs[i].getaddress()<<" "<<rs[i].getsalary()<<" "<<rs[i].getallowance()<<" "<<rs[i].getold_age_pension()<<" "<<rs[i].getHousing_Fund()<<" "<<rs[i].getmedical_insurance()<<" ";}f.close();}void modify_address_t(string num) {get_tstxt();for(int i=0; i<x; i++) {if(ts[i].getnumber()==num) {cout<<"已找到该员工,请输入该员工新的家庭住址;"<>new_address;ts[i].setaddress(new_address);cout<<"修改成功!!"<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核对员工信息!"<<endl;break;}}fstream fc("Temporary_staff.txt",ios::trunc);fc.close();fstream f;f.open("Temporary_staff.txt",ios::out);for(int i=0; i<x; i++) {f<<ts[i].getnumber()<<" "<<ts[i].getname()<<" "<<ts[i].getsex()<<" "<<ts[i].getaddress()<<" "<<ts[i].getsalary()<<" "<<ts[i].getbonus()<<" ";}f.close();}void modify_salary_r(string num) { //修改工资 清屏 重新输入 正式get_rstxt();for(int i=0; i<x; i++) {if(rs[i].getnumber()==num) {cout<<"已找到该员工,请输入该员工新的基础工资;"<>new_salary;rs[i].setsalary(new_salary);cout<<"修改成功!!"<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核对员工信息!"<<endl;break;}}fstream fc("Regular_staff.txt",ios::trunc);fc.close();fstream f;f.open("Regular_staff.txt",ios::out);for(int i=0; i<x; i++) {f<<rs[i].getnumber()<<" "<<rs[i].getname()<<" "<<rs[i].getsex()<<" "<<rs[i].getaddress()<<" "<<rs[i].getsalary()<<" "<<rs[i].getallowance()<<" "<<rs[i].getold_age_pension()<<" "<<rs[i].getHousing_Fund()<<" "<<rs[i].getmedical_insurance()<<" ";}f.close();}void modify_salary_t(string num) {get_tstxt();for(int i=0; i<x; i++) {if(ts[i].getnumber()==num) {cout<<"已找到该员工,请输入该员工新的基础工资;"<>new_salary;ts[i].setsalary(new_salary);cout<<"修改成功!!"<<endl;break;}if(i==x-1) {cout<<"抱歉,未查询到该员工,请核对员工信息!"<<endl;break;}}fstream fc("Temporary_staff.txt",ios::trunc);fc.close();fstream f;f.open("Temporary_staff.txt",ios::out);for(int i=0; i<x; i++) {f<<ts[i].getnumber()<<" "<<ts[i].getname()<<" "<<ts[i].getsex()<<" "<<ts[i].getaddress()<<" "<<ts[i].getsalary()<<" "<<ts[i].getbonus()<<" ";}f.close();}void print_num_r() {//打印员工信息 正式get_rstxt();for(int i=0; i<x; i++) {cout<<endl<<"员工编号:"<<rs[i].getnumber()<<" 员工姓名:"<<rs[i].getname()<<endl<<endl;cout<<"员工地址:"<<rs[i].getaddress()<<endl<<endl;cout<<"员工性别:"<<rs[i].getsex()<<" 员工税后实际工资:"<<rs[i].getreal()<<endl<<endl;cout<<"--------------------------------------------------------------------"<<endl;}}void print_num_t() {get_tstxt();for(int i=0; i<x; i++) {cout<<endl<<"员工编号:"<<ts[i].getnumber()<<" 员工姓名:"<<ts[i].getname()<<endl<<endl;cout<<"员工地址:"<<ts[i].getaddress()<<endl<<endl;cout<<"员工性别:"<<ts[i].getsex()<<" 员工税后实际工资:"<<ts[i].getreal()<<endl<<endl;cout<<"--------------------------------------------------------------------"<<endl;}}void print_num(int type) {int i,j,o = type;get_rstxt();get_tstxt();Regular_staff temp_r;Temporary_staff temp_t;cout<<"按编号由低到高输出:"<<endl<<"--------------------------------------------------------------------"<<endl;// cout<<"按编号顺序输出:1.正式员工 2.临时员工"<<endl<<"请输入:"<>o;switch(o) {case 1:for (j=0; j<x; j++) {for (i=0; irs[i+1].getnumber()) {temp_r=rs[i];rs[i]=rs[i+1];rs[i+1]=temp_r;}}}print_num_r();break;case 2:for (j=0; j<x; j++) {for (i=0; its[i+1].getnumber()) {temp_t=ts[i];ts[i]=ts[i+1];ts[i+1]=temp_t;}}}print_num_t();break;}}void print_sequence(int type) {int i,j,o = type;get_rstxt();get_tstxt();Regular_staff temp_r;Temporary_staff temp_t;cout<<"按工资由低到高输出:"<<endl<<"--------------------------------------------------------------------"<<endl;//cout<<"按工资由高到低输出:1.固定员工 2.临时员工"<<endl<<"请输入:"<>o;switch(o) {case 1:for (j=0; j<x; j++) {for (i=0; i<x-j; i++) {if (rs[i].getreal()<rs[i+1].getreal()) {temp_r=rs[i];rs[i]=rs[i+1];rs[i+1]=temp_r;}}}print_num_r();break;case 2:for (j=0; j<x; j++) {for (i=0; i<x-j; i++) {if (ts[i].getreal()<ts[i+1].getreal()) {temp_t=ts[i];ts[i]=ts[i+1];ts[i+1]=temp_t;}}}print_num_t();break;}}void print_flashback(int type) {int i,j,o = type;get_rstxt();get_tstxt();Regular_staff temp_r;Temporary_staff temp_t;cout<<"按工资由低到高输出:"<<endl<<"--------------------------------------------------------------------"<<endl;//cout<<"按工资由低到高输出:1.固定员工 2.临时员工"<<endl<<"请输入:"<>o;switch(o) {case 1:for (j=0; j<x; j++) {for (i=0; irs[i+1].getreal()) {temp_r=rs[i];rs[i]=rs[i+1];rs[i+1]=temp_r;}}}print_num_r();break;case 2:for (j=0; j<x; j++) {for (i=0; its[i+1].getreal()) {temp_t=ts[i];ts[i]=ts[i+1];ts[i+1]=temp_t;}}}print_num_t();break;}}int type;void charge_type() {while(1) {cls();printf("请选择职工类型\n\n1 正式职工\n\n2 临时职工\n\n");//输入职工类型cin >>type;if(type != 1 && type !=2) {//判断类型是否输入合法cls();printf("\n职工类型输入错误!x_x\n请重试!");Sleep(1500);continue;} else break;}}void print_opt1() {printf("\n\t\t 1 查找员工信息\n\n");printf("**************************************************\n\n");printf("1 职工姓名\n\n2 职工编号\n\n3 工资介于a到b的职工\n\n");printf("**************************************************\n\n");printf("请选择:");}void opt1() {string num1;while(1) {cls();print_opt1(); cin>>num1;if(num1 == "1") {charge_type();cls();cout <<"请输入员工姓名:"<> n;cout<<endl;if(type == 1) {find_name_r(n);} else if(type == 2) {find_name_t(n);}break;}if (num1 == "2") {charge_type();cls();cout <<"请输入员工编号:"<> n;cout<<endl;if(type == 1) {find_number_r(n);} else if(type == 2) {find_number_t(n);}break;}if (num1 == "3") {charge_type();cls();cout <<"请输入工资范围(最小值和最大值):"<> a >> b;cout<b) {double temp;temp = a;a = b;b = temp;}if(type == 1) {find_salary_r(a,b);} else if(type == 2) {find_salary_t(a,b);}break;} else {printf("\n员工信息输入错误!x_x\n请重试!");Sleep(1500);continue;}}}void print_opt2() {printf("\n\t\t 2 更新员工数据\n\n");printf("**************************************************\n\n");printf("1 新增员工数据\n\n2 修改员工数据\n\n3 返回主界面\n\n");printf("**************************************************\n\n");printf("请选择:");}void opt2() {string num2;while(1) {cls();print_opt2();cin >> num2;if(num2=="1") {cls();charge_type();cls();if(type == 1) {modify_new_r();}if(type == 2) {modify_new_t();}break;}if (num2 == "2") {cls();charge_type();cls();printf("\n\n1 修改员工地址\n\n2 修改员工工资\n\n请选择:");int n;cin >> n;cls();string m;printf("\n\n请输入员工编号:");cin>>m;if(type ==1) {cls();if(n ==1) modify_address_r(m);if(n ==2) modify_salary_r(m);}if(type ==2) {cls();if(n ==1) modify_address_t(m);if(n ==2) modify_salary_t(m);}break;}if(num2=="3") {cls();break;} else {cls();printf("\n输入错误!x_x\n\n请重试\n\n");Sleep(1500);continue;}}}void print_opt3() {printf("\n\t\t 3 输出员工信息\n\n");printf("**************************************************\n\n");printf("1 按工资由高到低输出 \n\n2 按工资由低到高输出\n\n3 按编号输出(低到高)\n\n4 返回主界面\n\n");printf("**************************************************\n\n");printf("请选择:");}void opt3() {string num3;while(1) {cls();print_opt3();cin >> num3;if(num3 == "1") {cls();charge_type();cls();print_sequence(type);break;}if(num3 == "2") {cls();charge_type();cls();print_flashback(type);break;}if(num3 == "3") {cls();charge_type();cls();print_num(type);break;}if(num3 == "4") {cls();break;} else {cls();cout<<"请输入正确的选项!"<> opt;o=atoi(opt.c_str());switch(o) {case 1:opt1();system("pause");refresh();break;case 2:opt2();system("pause");refresh();break;case 3:opt3();system("pause");refresh();break;case 4:opt4();Sleep(500) ;return 0;default:cls();opt_error();system("pause");refresh();break;}}}