首页 > 编程知识 正文

职工信息管理系统的设计思路(信息管理系统)

时间:2023-05-04 19:17:38 阅读:76269 作者:4196

上传代码

(类) include iostream # include algorithm # includeiomanipusingnamespacestd; class staff//员工基本信息类{private:char name[6]; Int编号器; char department[6]; int wage; char position[6]; public : staff { } friendclasscompany; (; class company//公司系{private:staff M[100]; int num; 输入计数; public:company () {num=0; 计数=0; //默认构造函数初始化语音添加停止(; void Findstaff (; void显示staff (; void Deletionstaff (; (; 请输入voidcompany:3360addstaff(/员工信息添加函数({cout )员工编号: ); Int编号器; cinnumber; for(intI=0; inum; I ) while(number==m[I].number ) {cout )此员工编号已存在。 请重新输入: )。 cinnumber; }}M[num].number=number; cout '员工姓名: '; cinM[num].name; cout '员工所属部门: '; cinM[num].department; cout '员工工资: '; cinM[num].wage; cout '员工职位: '; cinM[num].position; num; count=num; ) void company : find staff (//员工信息检索函数({int number; cout '员工编号: '; cinnumber; int i; for(I=0; icount; I () if ) m[I].number==number ) ) {cout '姓名: ); coutM[i].nameendl; cout '部门: '; coutM[i].departmentendl; cout '工资: '; coutM[i].wageendl; cout '后: '; coutM[i].positionendl; i=-1; 布雷克; }if(I!=-1|||I==count(cout )没有此员工信息。' endlendl; } void company :3360 display staff (/员工信息显示函数(if ) num=0) {cout抱歉,您尚未输入员工信息。 输入后显示“endl; 在}else{cout中输入的员工信息如下。 ' endlendl; cout '号码' setw(6)姓名' setw(6)部门' setw(6)工资' setw(6)职位' endl; for(intI=0; icount; I () coutm[I].numbersetw ) ) 6; coutm[I].namesetw(6; coutm [ I ] .部门集(6; coutm[I].wagesetw(6; coutM[i].positionendl; } } void company :3360 deletion staff (//员工信息删除函数({int number; int p=0; //请输入要删除的员工编号:以确定该员工是否有cout; cinnumber; for(intI=0; icount; I () if ) m[I].number==number ) ) p=1; for(intj=I; jcount; j ) m(j )=m ) j1 ); 布雷克; }if(p==0) coutendl )没有此员工信息,删除失败!' endlendl; if(p==1) {计数- -; coutendl '删除成功!' endlendl; }}void welcome ()//系统主菜单) {cout' 'endl; 出局了

<" $----------------------------------$ "<<endl;cout<<" | | "<<endl;cout<<" | **欢迎进入公司职工信息管理程序** | "<<endl; cout<<" | | "<<endl; cout<<" $----------------------------------$ "<<endl<<endl;cout<<"请选择您的操作:"<<endl;cout<<" 1.增加职工信息"<<endl;cout<<" 2.查找职工信息"<<endl;cout<<" 3.显示所有职工信息"<<endl;cout<<" 4.删除职工信息"<<endl;cout<<" 0.退出"<<endl<<endl;cout<<"请输入编号0-4: ";}int main(){int z;cout<<"制作者:十七"<<endl; company al;while(1){welcome();cin>>z;if(z==1){cout<<endl;cout<<"增加职工信息"<<endl<<endl;al.Addstaff();}if(z==2){cout<<endl<<"查找职工信息"<<endl<<endl;al.Findstaff();}if(z==3){cout<<endl<<"显示所有职工信息"<<endl<<endl;al.Displaystaff();} if(z==4){cout<<endl<<"删除职工信息"<<endl<<endl;al.Deletionstaff();}if(z==0){cout<<endl<<"已经为您退出该程序."<<endl;break;}}return 0;}(结构体)#include<iostream>#include<cstring>#include<cmath>#include<algorithm>#include<iomanip>using namespace std;class Staff{public: string name;//姓名 int no;//职员号 string dep;//职员所在的部门 int wage;//工资 string posi;//职位 };int main(){ cout<<"制作者:十七"<<endl;Staff member[100];int mem=0;//记录输入人数 cout<<endl<<endl<<endl;cout<<setw(5)<<" "<<"$----------------------------------------$"<<endl;cout<<setw(5)<<" "<<"! !"<<endl;cout<<setw(5)<<" "<<"! **欢迎进入公司职员信息管理系统** !"<<endl;cout<<setw(5)<<" "<<"! !"<<endl;cout<<setw(5)<<" "<<"$----------------------------------------$"<<endl;cout<<endl<<endl;while(1){cout<<"请选择您的操作: "<<endl<<endl;cout<<setw(10)<<" "<<"1 增加职工信息"<<endl;cout<<setw(10)<<" "<<"2 查找职工信息"<<endl;cout<<setw(10)<<" "<<"3 显示所有职工信息"<<endl;cout<<setw(10)<<" "<<"4 删除职工信息"<<endl; cout<<setw(10)<<" "<<"0 退出"<<endl<<endl<<endl;cout<<"请输入序号0-4: ";int a;cin>>a;if(a<0||a>4)cout<<endl<<"输入错误请重新输入!"<<endl<<endl; if(a==0) break;if(a==1)//增加职工信息{mem++;cout<<endl<<"请输入职工姓名: ";cin>>member[mem].name;for(int i=0;i<mem;i++){if(member[i].name==member[mem].name){cout<<endl<<"这个职工已存在,无法加入!"<<endl;break;}}cout<<endl<<"请输入职工号: ";cin>>member[mem].no;cout<<endl<<"请输入职工部门: ";cin>>member[mem].dep;cout<<endl<<"请输入职工工资: ";cin>>member[mem].wage;cout<<endl<<"请输入职工职位: ";cin>>member[mem].posi;cout<<endl<<"职工添加成功!"<<endl<<endl; }if(a==2)//查找职工信息{int hao;int p=0;//p判断该职工是否存在 cout<<endl<<"请输入要查找的职工号: "; cin>>hao; for(int i=1;i<=mem;i++) { if(hao==member[i].no)//该职工存在 { p=1; cout<<endl<<"职工信息已找到!"<<endl<<endl; cout<<"姓名"<<setw(5)<<" "<<"职工号"<<setw(4)<<" "; cout<<"部门"<<setw(5)<<" "<<"工资"<<setw(5)<<" "<<"职务"<<endl; if(member[i].no !=0) { cout<<member[i].name<<setw(5)<<" "; cout<<member[i].no<<setw(5)<<" "; cout<<member[i].dep<<setw(5)<<" "; cout<<member[i].wage<<setw(5)<<" "; cout<<member[i].posi; } } cout<<endl<<endl; } if(p==0) { cout<<endl<<setw(5)<<" "; cout<<"该职工不存在!"<<endl; cout<<endl; } } if(a==3)//显示所有职工信息{cout<<endl;cout<<"姓名"<<setw(5)<<" "<<"职工号"<<setw(4)<<" "<<"部门";cout<<setw(5)<<" "<<"工资"<<setw(5)<<" "<<"职务"<<endl;for(int i=1;i<=mem;i++){if(member[i].no!=0){ cout<<member[i].name; cout<<setw(5)<<" "; cout<<member[i].no; cout<<setw(5)<<" "; cout<<member[i].dep; cout<<setw(5)<<" "; cout<<member[i].wage; cout<<setw(5)<<" "; cout<<member[i].posi; cout<<endl; }}cout<<endl;}if(a==4){int Dele;cout<<endl;cout<<"请输入要删除的职工号: ";cin>>Dele;cout<<endl;int b;for(int i=1;i<=mem;i++){if(Dele==member[i].no){b=mem;break;} } member[b].name='0';member[b].no=0;member[b].dep='0';member[b].wage=0;member[b].posi='0';cout<<"您已成功删除该职工的信息!";cout<<endl<<endl; } }return 0;}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。