当前位置:文档之家› 简单员工管理系统

简单员工管理系统

简单员工管理系统数据结构课程设计报告第11页,共19页数据结构课程设计报告第12页,共19页附录(源程序清单) 七 附录(源程序清单)#include <iostream>数据结构课程设计报告#include <string.h> using namespace std; class bd { public: int y; int m; int day; }; class staff { private: char no[8];//编号 char name[20];//姓名 char sex[4];//性别 bd bday; //出生年月 char sr[10];//学历 char jp[10];//职务 char tel[12]; //电话号码 char ad[30]; //住址 public: staff(); void init(staff *p); void sch(staff *p); void upd(staff *p); void ins(staff *p); void del(staff *p); void sort(staff *p); staff *next; }; staff::staff() //构造函数初始化 { strcpy(no,"0000"); strcpy(name," bday.y=0; bday.m=0; bday.day=0; strcpy(sex," "); strcpy(sr," strcpy(jp," strcpy(tel," strcpy(ad," "); "); "); "); ");第13页,共19页数据结构课程设计报告next=NULL; } void staff::init(staff *p) { int flag=1; do { staff *q=new staff; if(!q) { cout <<"\n" <<"分配空间失败!"; return; } cout <<"\n" <<"请输入员工的编号:"; cin>>q->no; cout <<"\n" <<"请输入员工的姓名:"; cin>>q->name; cout <<"\n" <<"请输入员工的性别:"; cin>>q->sex; cout <<"\n" <<"请输入员工的出生年份:"; cin>>q->bday.y; cout <<"\n" <<"请输入员工的出生月份:"; cin>>q->bday.m; cout <<"\n" <<"请输入员工的出生日份:"; cin>>q->bday.day; cout <<"\n" <<"请输入员工的学历:"; cin>>q->sr; cout <<"\n" <<"请输入员工的职务:"; cin>>q->jp; cout <<"\n" <<"请输入员工的电话号码或手机号码:"; cin>>q->tel; cout <<"\n" <<"请输入员工的住址:"; cin>>q->ad; q->next=p->next; p->next=q; cout <<"\n" <<"结束输入请输入,否则输入:"; cin>>flag; }while(flag); } void staff::sch(staff *p) { staff *q; q=p->next; char a[20]; cout <<"\n" <<"请输入查找对象的编号或姓名:";第14页,共19页数据结构课程设计报告cin>>a; while(q) { if(!strcmp(a,q->no)||!strcmp(a,q->name)) { cout <<"\n" <<"员工的编号:"; cout <<q->no; cout <<"\n" <<"员工的姓名:"; cout <<q->name; cout <<"\n" <<"员工的性别:"; cout <<q->sex; cout <<"\n" <<"员工的出生年月日:";第15页,共19页cout <<q->bday.y <<"." <<q->bday.m <<"." <<q->bday.day; cout <<"\n" <<"员工的学历:"; cout <<q->sr; cout <<"\n" <<"员工的职务:"; cout <<q->jp; cout <<"\n" <<"员工的电话号码或手机号码:"; cout <<q->tel; cout <<"\n" <<"员工的住址:"; cout <<q->ad; return; } q=q->next; } if(!q) cout <<"\n" <<"查找对象没找到!"; } void staff::upd(staff *p) { staff *q; char a[8]; q=p->next; cout <<"\n" <<"请输入修改对象的编号:"; cin>>a; while(q) { if(!strcmp(a,q->no)) { int i; cout <<"\n" <<"请输入修改编号" <<a <<"员工信息选项:"; cout <<"\n" <<" cout <<"\n" <<" cout <<"\n" <<" cout <<"\n" <<" cout <<"\n" <<" 1 编号"; 2 姓名"; 3 学历"; 4 职务"; 5 电话号码或手机号码";数据结构课程设计报告cout <<"\n" <<" cin>>i; switch(i) { 6 住址" <<endl;第16页,共19页case 1: cout <<"\n" <<"请输入员工新编号:";cin>>q->no;return; case 2: cout <<"\n" <<"请输入员工新姓名:";cin>>q->name;return; case 3: cout <<"\n" <<"请输入员工新学历:";cin>>q->sr;return; case 4: cout <<"\n" <<"请输入员工新职务:";cin>>q->jp;return; case 5: cout <<"\n" <<"请输入员工新电话号码或手机号码:";cin>>q->tel;return; case 6: cout <<"\n" <<"请输入员工新住址:";cin>>q->ad;return; default: cout <<"\n" <<"输入错误!";return; } } q=q->next; } if(!q) cout <<"\n" <<"修改对象没找到!"; } void staff::ins(staff *p) { int flag=1; do { staff *q=new staff; if(!q) { cout <<"\n" <<"分配空间失败!"; return; } cout <<"\n" <<"请输入插入员工的编号:"; cin>>q->no; cout <<"\n" <<"请输入插入员工的姓名:"; cin>>q->name; cout <<"\n" <<"请输入插入员工的性别:"; cin>>q->sex; cout <<"\n" <<"请输入插入员工的出生年份:"; cin>>q->bday.y; cout <<"\n" <<"请输入插入员工的出生月份:"; cin>>q->bday.m; cout <<"\n" <<"请输入插入员工的出生日份:"; cin>>q->bday.day; cout <<"\n" <<"请输入插入员工的学历:"; cin>>q->sr; cout <<"\n" <<"请输入插入员工的职务:"; cin>>q->jp; cout <<"\n" <<"请输入插入员工的电话号码或手机号码:";数据结构课程设计报告cin>>q->tel; cout <<"\n" <<"请输入插入员工的住址:"; cin>>q->ad; q->next=p->next; p->next=q; cout <<"\n" <<"结束插入员工请输入,否则输入:"; cin>>flag; } while(flag); } void staff::del(staff *p) { staff *q,*t; char a[8]; cout <<"\n" <<"请输入删除对象的编号:"; cin>>a; q=p; while(q->next) { if(!strcmp(a,q->next->no)) { t=q->next; q->next=t->next; delete t; cout <<"\n" <<"删除离职员工成功!"; return; } q=q->next; } if(!q->next) cout <<"\n" <<"该员工不存在!" <<endl; } void staff::sort(staff *p) { staff *q,*t,*m,*n=new staff,*s; int i=0; t=p->next; while(t) { i++; t=t->next; } while(i) { s=p; m=s->next; q=p->next->next;第17页,共19页数据结构课程设计报告while(m&&q) { if(strcmp(q->no,m->no)<0) { n=q->next; s->next=q; q->next=m; m->next=n; s=q; q=q->next->next; } else { m=m->next; q=q->next; s=s->next; } } i--; } cout <<"\n" <<"排序后的结果:" <<endl; q=p->next; while(q) { cout <<"\n" <<"员工的编号:"; cout <<q->no; cout <<"\n" <<"员工的姓名:"; cout <<q->name; cout <<"\n" <<"员工的性别:"; cout <<q->sex; cout <<"\n" <<"员工的出生年月:";第18页,共19页cout <<q->bday.y <<"." <<q->bday.m <<"." <<q->bday.day; cout <<"\n" <<"员工的学历:"; cout <<q->sr; cout <<"\n" <<"员工的职务:"; cout <<q->jp; cout <<"\n" <<"员工的电话号码或手机号码:"; cout <<q->tel; cout <<"\n" <<"员工的住址:"; cout <<q->ad; q=q->next; } } //#include"类.h"数据结构课程设计报告void main() { staff *h=new staff; if(!h) { cout <<"分配空间失败!" <<endl; return; } int i=9; do { cout <<"\n" <<" cout <<" cout <<" cout <<" cout <<" cout <<" cout <<" cout <<" cin>>i; switch(i) { case 0:return; case 1:h->init(h);break; case 2:h->sch(h);break; case 3:h->upd(h);break; case 4:h->ins(h);break; case 5:h->del(h);break; case 6:h->sort(h);break; default:cout <<"输入错误请重新输入!" <<endl; } } while(i); }第19页,共19页欢迎使用员工管理系统 " <<endl; 0退出员工管理系统" <<endl; 1初始化员工表" <<endl; 2查询" <<endl; 3修改" <<endl; 4插入" <<endl; 5删除" <<endl; 6排序" <<endl;cout <<" 请输入您的选项:" <<endl;。

相关主题