C员工工资管理方案计划系统源代码.doc

上传人:小** 文档编号:3003135 上传时间:2020-06-20 格式:DOC 页数:17 大小:80.02KB
返回 下载 相关 举报
C员工工资管理方案计划系统源代码.doc_第1页
第1页 / 共17页
C员工工资管理方案计划系统源代码.doc_第2页
第2页 / 共17页
点击查看更多>>
资源描述

《C员工工资管理方案计划系统源代码.doc》由会员分享,可在线阅读,更多相关《C员工工资管理方案计划系统源代码.doc(17页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、.#include #include #include #include #include #include using namespace std;#define NULL 0#define LEN sizeof(struct student) int const N=20;void Menu(); void Pass();int n=0; /定义一个全局变量统计职工人数 /-定义一个职工信息的结构体struct student char nameN; /用来存放姓名char sexN; /用来存放性别long id; /用来存放编号float paid3; /用来存放工资int total

2、; /用来存放总工资struct student *next;/-职工类class Information public:Information() ; /构造函数. Information() ; /析构函数. student *creat(); /建立链表void output(student *head); /显示职工信息int count(student *head); /定义函数count()统计职工总数student *insert(student*head); /指针函数*insert()用来添加职工信息.student *cancel(student *head,long id

3、); /指针函数*cancel()用来删除职工信息.student *find(student *head,long id); /指针函数*find()用来查找职工信息.student *modify(student *head,long id); /指针函数*modife()用来修改职工的信息.void paixu(student *head); /定义paixu()函数将职工的总额从大到小排列并输出void average(student *head); /定义职工工资平均值的函数void save(student *head); /保存文件信息student *Read(); /读取文件

4、信息private:student *p1,*p2,*p3,*head,st; ;Information:Information() cout *n;cout -n; cout *nn; Information:Information() cout n;cout n;cout 本系统管理员 n;cout n;cout n;cout -n; cout n;cout n;cout 欢迎下次使用 n;cout n;cout n;cout 再见 n;cout n;cout建立链表信息student *Information:creat(void) /定义一个指向struct student的结构体指针

5、函数*creat()用来录入职工信息. char chN;n=0; /用来存放职工姓名 p1=p2=(student *)malloc(LEN);/调用malloc()函数用来开辟一个新的存储单元 cout -endl;coutch;head=NULL; /给指针head赋初值while (strcmp(ch,#)!=0) /调用字符比较函数strcmp()用来判断是否继续输入p1=(student *)malloc(LEN); /调用malloc()函数用来开辟一个新的存储单元strcpy(p1-name,ch); /将循环结构前面输入的姓名复制到结构体名为p1的数组name中coutp1-

6、sex;coutp1-id;while(p1-id)id)100000) /判断输入的编号是否有效(100000个)cout0p1-id; coutp1-paid0;while(p1-paid0)paid0)100000) /判断输入的分数是否有效(=0 =100000)cout0p1-paid0; coutp1-paid1;while(p1-paid1)paid1)100000) /判断输入的分数是否有效(=0 =100000)cout0p1-paid1; coutp1-paid2;while(p1-paid2)paid2)100000) /判断输入的分数是否有效(=0 =100000)co

7、ut0p1-paid2; p1-total=p1-paid0+p1-paid1+p1-paid2; /计算总额 if(n=0)head=p1; /如果是输入第一组职工信息就将指针p1赋给指针headelse p2-next=p1; /否则将p1赋给p2所指结构体的next指针p2=p1; /将指针p1赋给指针p2n+; /将职工人数n的值加1coutch; /将输入的姓名存放到字符数组ch中p2-next=NULL; /将p2所指结构体的next指针重新赋空值return (head);/将输入的第一组职工信息返回/-定义output()函数将职工的信息从头指针所指内容开始输出void Inf

8、ormation:output(student *head) system(cls);if(head=NULL) cout 这是一个空表,请先输入员工信息!n;elsecout-n;cout *职工工资信息表*n;cout-n; cout|编 号| |姓 名| |性别| |基本工资| |加班工资| |其他奖金| |总额|n;cout-n; p1=head; /将头指针赋给p docoutsetw(6)idsetw(10)namesetw(10)sexsetw(10)paid0setw(10)paid1setw(12)paid2setw(12)totalendl;coutnext; /将下一组职

9、工信息的next指针赋给pwhile(p1!=NULL); /若指针p非空则继续,目的是把所有的职工信息都传给指针p然后输出./-统计职工人数的函数int Information:count(struct student *head) /定义函数count()统计职工总数if(head=NULL)return(0); /若指针head为空返回值为0else return(1+count(head-next); /函数的递归调用/-添加职工的成绩的函数student *Information:insert( student *head) /插入新结点定义一个指向struct student的结构

10、体指针函数*insert()用来添加职工信息.system(cls);coutt-nendl;p1=(student *)malloc(LEN); /使p1指向插入的新结点coutp1-id;while(p1-id)id)100000)cout0p1-id; /将输入的编号存放到p1所指结构体的数组id中 coutp1-name; /将输入的姓名存放到结构体名为p1的数组name中coutp1-sex; coutp1-paid0;while(p1-paid0)paid0)100000)cout0p1-paid0; /将输入的基本工资存放到p1所指结构体的数组paid中coutp1-paid1;

11、while(p1-paid1)paid1)100000)cout0p1-paid1; /将输入的加班工资存放到p1所指结构体的数组paid中coutp1-paid2;while(p1-paid2)paid2)100000)cout0p1-paid2; /将输入的其他奖金存放到p1所指结构体的数组paid中 p1-total=p1-paid0+p1-paid1+p1-paid2;/计算总分 p2=head; /将头指针赋给p2if(head=NULL) /若没调用次函数以前的头指针head为空head=p1;p1-next=NULL; /则将p1赋给头指针head并将p1所指结构体成员指针nex

12、t赋空值else while(p1-idp2-id)&(p2-next!=NULL)p3=p2; /p3指向原p2指向的结点p2=p2-next; /p2后移一个结点if(p1-idid)if(head=p2)p1-next=head;head=p1; /插入到第一个结点之前else p3-next=p1;p1-next=p2; /插入到p3所指结点之后elsep2-next=p1;p1-next=NULL; /插入到尾结点之后n+; /将职工人数加1coutt-删除职工信息student *Information:cancel(student *head,long id) /定义一个指向st

13、ruct student的结构体指针函数*delete()用来删除考生信息. system(cls);if(head=NULL) /若调用次函数以前的头指针head为空 return(head);elsep1=head; /否则将头指针赋给p1while(id!=p1-id&p1-next!=NULL) /寻找要删除的结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空p2=p1;p1=p1-next; /p2指向原p1指向的结点p1后移一个结点if(id=p1-id) /如果输入的职工编号是p1所指的职工编号/结点找到后删除if(p1=head) head=p1-nex

14、t; /如果head指针和p1指针相等则将下一个结点赋给指针head else p2-next=p1-next; /否则将p1所指结点赋给p2所指结点将要删除的职工信息跳过去cout 删除编号为id的职工n;n-; /将职工人数减1 return(head); /将头指针返回/*修改职工数据*/student *Information:modify(student *head,long id)system(cls);coutt-nid&p1-next!=NULL)/寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空p1=p1-next; /p2指向原p1指向的结点p

15、1后移一个结点 if(id=p1-id) /如果要查找的职工编号是p1所指的职工编号cout你需要修改的员工信息如下:n;cout-n;cout|编 号| |姓 名| |性别| |基本工资| |加班工资| |其他奖金| |总额|n;cout-n;coutsetw(6)idsetw(10)namesetw(10)sexsetw(10)paid0setw(10)paid1setw(12)paid2setw(12)totalendl;cout-n;coutp1-id;while(p1-id)id)100000)cout0p1-id; /将输入的编号存放到p1所指结构体的数组id中 coutp1-na

16、me; /将输入的姓名存放到结构体名为p1的数组name中coutp1-sex; coutp1-paid0;while(p1-paid0)paid0)100000)cout0p1-paid0; /将输入的基本工资存放到p1所指结构体的数组paid中coutp1-paid1;while(p1-paid1)paid1)100000)cout0p1-paid1; /将输入的加班工资存放到p1所指结构体的数组paid中coutp1-paid2;while(p1-paid2)paid2)100000)cout0p1-paid2; /将输入的其他奖金存放到p1所指结构体的数组paid中 p1-total=

17、p1-paid0+p1-paid1+p1-paid2; /计算总分 else cout 需要修改的信息中没有编号为id查找职工信息student *Information:find(student *head,long id) /定义一个指向struct student的结构体指针函数*find()用来查找职工信息.system(cls);if(head=NULL) /若调用次函数以前的头指针head为空coutid&p1-next!=NULL)/寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空p1=p1-next; /p2指向原p1指向的结点p1后移一个结点if

18、(id=p1-id) /如果要查找的职工编号是p1所指的职工编号cout-n;cout|编 号| |姓 名| |性别| |基本工资| |加班工资| |其他奖金| |总额|n;cout-n;coutsetw(6)idsetw(10)namesetw(10)sexsetw(10)paid0setw(10)paid1setw(12)paid2setw(12)totalendl;cout-n;else cout信息中没有编号为id的员工.n; /结点没找到return(head);/-定义paixu()函数将职工的工资总额从大到小排列并输出void Information:paixu(student

19、*head) system(cls);int i,k,m=0,j;student *pN;/定义一个指向struct student的结构体指针数组p if(head!=NULL)/如果头指针是空则继续 m=count(head);cout-n;cout *员工工资统计表*n;cout-n;cout|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额| |名次|n;cout-n;p1=head;for(k=0;knext;for(k=0;km-1;k+) /选择排序法for(j=k+1;jtotaltotal)p2=pk;pk=pj;pj=p2; /从大到小排列的指针

20、 for(i=0;im;i+)coutsetw(6)idsetw(8)namesetw(9)sexsetw(10)paid0setw(10)paid1setw(10)paid2setw(10)totalsetw(10)i+1endl;cout求各工资的平均值的函数void Information:average(student *head)int k,m;float arg1=0,arg2=0,arg3=0;if(head=NULL)/如果头指针是空则继续cout 这是一个空表,请先输入员工信息!n;elsem=count(head);p1=head;for(k=0;kpaid0;arg2+=

21、p1-paid1;arg3+=p1-paid2;p1=p1-next;arg1/=m;arg2/=m;arg3/=m;cout *各项工资的平均值*n;cout-n;couttt基本工资的平均值: setw(4)arg1ntt加班工资的平均值: setw(4)arg2ntt奖金的平均值: setw(4)arg3n;cout保存函数.void Information:save(student *head) system(cls); ofstream out(data.txt,ios:out); outcount(head)endl; while(head!=NULL) outnamet idtt

22、 sext paid0t paid1t paid2t totalnext; /读取文件的信息student *Information:Read() system(cls); int i=0; p1=p2=( student *)malloc(LEN); head=NULL; ifstream in(data.txt,ios:in); ini; if(i=0)cout data 文件中的数据为空,请先输入数据!endl; return 0; else coutn原文件已保存的信息如下:n; cout endl; cout|姓 名| |编 号| |性别| |基本工资| |加班工资| |其他奖金|

23、|总额|n; cout 0;i-) p1=(student *)malloc(LEN); inst.namest.idst.sex st.paid0st.paid1st.paid2st.total; strcpy(p1-name,st.name); p1-id=st.id; strcpy(p1-sex,st.sex); p1-paid0=st.paid0; p1-paid1=st.paid1; p1-paid2=st.paid2; p1-total=st.total; if(n=0)head=p1; /如果是输入第一组职工信息就将指针p1赋给指针head else p2-next=p1; /否

24、则将p1赋给p2所指结构体的next指针 p2=p1; /将指针p1赋给指针p2 n+; /将n的值加1 /显示读入数据 cout namet id t sex t paid0 t paid1 t paid2 t totalendl; cout endl;cout 数据已经成功读取完毕!nnnext=NULL;in.close(); return (head); /-菜单void Menu() Information person; student *head=NULL; int choice; long i; head=person.Read(); do couttendl; coutt endl; coutt _ _ _ 欢迎进入员工信息统计管理 _ _ _ endl; coutt endl; coutt

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 其他杂项

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com