数据结构--员工管理信息系统代码.doc_第1页
数据结构--员工管理信息系统代码.doc_第2页
数据结构--员工管理信息系统代码.doc_第3页
数据结构--员工管理信息系统代码.doc_第4页
数据结构--员工管理信息系统代码.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

数据结构-员工管理信息系统源程序#include#include#include #include using namespace std;#define OK 1#define ERROR 0#define OVERFLOW -2typedef int Status;/Status 是函数返回值类型,其值是函数结果状态代码。#define MAXSIZE 100/顺序表可能达到的最大长度typedef struct /ElemType 为自定义的数据类型,要根据实际情况定义,本例为学生信息:(学号,成绩)int num;string name;string sex; string birth;string edu;string job;string phone; string add;ElemType; typedef struct /定义顺序表类型为ListElemType *elem;int length;List;void InitList(List &L)/创建空顺序表L.elem=new ElemTypeMAXSIZE; /动态分配空间L.length=0;void ListInput(List &L,int n)/输入顺序表数据int i;cout请输入员工信息endl;for(i=0;in;i+)cout请输入员工编号:L.elemi.num; /输入员工编号 cout请输入员工姓名L.; /输入姓名 cout请输入员工性别:L.elemi.sex; /输入员工编号cout请输入员工出生年月L.elemi.birth; cout请输入员工职务L.elemi.job; cout请输入员工学历L.; cout请输入员工电话号码L.elemi.phone; cout请输入员工住址L.elemi.add; L.length=n;void ListOutput(List L)/输出顺序表数据int i=0;if (L.length=0) cout空表,无数据输出!;for(i=0;iL.length;i+)cout(L.elemi.num,L.,L.elemi.birth,L.elemi.job,L.,L.elemi.phone, L.elemi.add)endl;/输出数据coutendl;int LocateElem(List L,int num) /在顺序表里查找某编号员工的信息int i;for(i=0;iL.length;i+)if(num=L.elemi.num)return i+1;else return 0;void ListInsert(List &L,ElemType e) /顺序表的插入 int i;if(L.length=MAXSIZE)cout存储空间已满;/当前存储空间已满 if(LocateElem(L,e.num)!=0)cout=0;i-) if (e.numL.elemi.num) L.elemi+1=L.elemi;/在查找位置的同时元素后移 else break;L.elemi+1=e;/将新元素e放入合适的位置+L.length;/表长增1void ListDelete(List &L,int bh) / 顺序表的删除int i,j;i=LocateElem(L,bh); /查找删除位置 if(i=0)cout找不到此员工相关信息; elsefor(j=i;j=L.length;j+)L.elemj-1=L.elemj;/被删除元素之后的元素前移-L.length;/表长减1void BubbleSort(List &L) int i,j; ElemType key; for(i=0;iL.length-1;i+) for(j=i+1;jL.elemj.num) key=L.elemi; L.elemi=L.elemj; L.elemj=key; void ChangeM(List &L)int i,n,num; coutttt* 请输入更改的员工编号 *num;coutttt*endl; coutttt* *endl; coutttt* 1 改名字 *endl; coutttt* 2 改电话 *endl; coutttt* 3 改性别 *endl; coutttt* 4 改学历 *endl; coutttt* 5 改住址 *endl; coutttt* 6 改编号 *endl; coutttt* 7 改工作 *endl; coutttt* 8 改生日 *endl; coutttt*n;coutttt* 请输入1-8选择修改项 *n;for(i=0;iL.length;i+) if(num=L.elemi.num) /查找删除位置 break; if(iL.length) switch(n) case 1: coutttt 请输入新内容:L.;break; case 2: coutttt 请输入新内容:L.elemi.phone;break; case 3: coutttt 请输入新内容:L.elemi.sex;break; case 4: coutttt 请输入新内容:L.;break; case 5: coutttt 请输入新内容:L.elemi.add;break; case 6: coutttt 请输入新内容:L.elemi.num;break; case 7: coutttt 请输入新内容:L.elemi.job;break; case 8: coutttt 请输入新内容:L.elemi.birth;break; else cout未找到要修改的员工信息,请检查是否编号输入有误!n;void menu(void) /主菜单system(cls);coutnn; coutttt 员工管理系统n; coutttt*n; coutttt* *n; coutttt* 1 数 据 输 入 *n; coutttt* 2 查 询 数 据 *n; coutttt* 3 更 新 数 据 *n; coutttt* 4 插 入 数 据 *n; coutttt* 5 删 除 数 据 *n; coutttt* 6 员 工 排 序 *n; coutttt* 7txt文件(员工信息) *n; coutttt* 8 文 件 导 出 *n; coutttt* 9 退 出 *n; coutttt* *n; coutttt* *n; coutttt*n; coutttt 请输入你的选项(1-8):;void newFile(List &L) int i; int num;string name; string sex; string birth; string edu; string job; string phone; string add; FILE *fp;if(fp=fopen(f1.txt,w)=NULL)coutfile open error!n;exit(0); for(i=0;iL.length;i+)num=L.elemi.num;name=L.; sex=L.elemi.sex; birth=L.elemi.birth; edu=L.; job=L.elemi.job; phone=L.elemi.phone; add=L.elemi.add; fprintf(fp,%d,num); fputs( ,fp); fputs(const char *)(name.c_str(),fp);fputs( ,fp); fputs(const char *)(sex.c_str(),fp); fputs( ,fp); fputs(const char *)(birth.c_str(),fp); fputs( ,fp); fputs(const char *)(edu.c_str(),fp); fputs( ,fp); fputs(const char *)(job.c_str(),fp); fputs( ,fp); fputs(const char *)(phone.c_str(),fp); fputs( ,fp); fputs(const char *)(add.c_str(),fp); fputs( ,fp);fputs(n,fp); fclose(fp); void readFile(List &L) FILE *fp;if(fp=fopen(f1.txt,r)=NULL)couti; switch(i) case 1: coutn;ListInput(L,n); ListOutput(L); break; case 2:coutn; m=LocateElem(L,n);if (m=0) cout数据不存在;else cout该员工的信息为:; coutL.elemm-1.num,L.,L.elemm-1.sex,L.elemm-1.birth,L.elemm-1.job,L.,L.elemm-1.phone,L.elemm-1.add ; break;case 3: ChangeM(L); ListOutput(L); break; case 4: cout请输入要插入的数据,endl; cout按以下顺序输入信息:编号、姓名、性别、出生年月、职务、学历、电话号码、地址。e.num; ; cine.sex; cine.birth; cine.job; ; cine.phone; cine.add; ListInsert(L,e); ListOutput(L); break; case 5: coutn; ListDelete(L,n); ListOutput(L);

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论