C++员工工资管理系统源代码.docx

上传人:b****6 文档编号:3238777 上传时间:2022-11-20 格式:DOCX 页数:23 大小:23.88KB
下载 相关 举报
C++员工工资管理系统源代码.docx_第1页
第1页 / 共23页
C++员工工资管理系统源代码.docx_第2页
第2页 / 共23页
C++员工工资管理系统源代码.docx_第3页
第3页 / 共23页
C++员工工资管理系统源代码.docx_第4页
第4页 / 共23页
C++员工工资管理系统源代码.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

C++员工工资管理系统源代码.docx

《C++员工工资管理系统源代码.docx》由会员分享,可在线阅读,更多相关《C++员工工资管理系统源代码.docx(23页珍藏版)》请在冰豆网上搜索。

C++员工工资管理系统源代码.docx

C++员工工资管理系统源代码

#include

#include

#include

#include

#include

#include

usingnamespacestd;

#defineNULL0

#defineLENsizeof(structstudent)

intconstN=20;

voidMenu();

voidPass();

intn=0;//定义一个全局变量统计职工人数

//——--------->定义一个职工信息的结构体

structstudent

{

charname[N];//用来存放姓名

charsex[N];//用来存放性别

longid;//用来存放编号

floatpaid[3];//用来存放工资

inttotal;//用来存放总工资

structstudent*next;

};

//-------------->职工类

classInformation

{

public:

Information();//构造函数.

~Information();//析构函数.

student*creat();//建立链表

voidoutput(student*head);//显示职工信息

intcount(student*head);//定义函数count()统计职工总数

student*insert(student*head);//指针函数*insert()用来添加职工信息.

student*cancel(student*head,longid);//指针函数*cancel()用来删除职工信息.

student*find(student*head,longid);//指针函数*find()用来查找职工信息.

student*modify(student*head,longid);//指针函数*modife()用来修改职工的信息.

voidpaixu(student*head);//定义paixu()函数将职工的总额从大到小排列并输出

voidaverage(student*head);//定义职工工资平均值的函数

voidsave(student*head);//保存文件信息

student*Read();//读取文件信息

private:

student*p1,*p2,*p3,*head,st;

};

Information:

:

Information()

{cout<<"******************************************************************************\n";

cout<<"------------------------<<欢迎您使用员工工资管理系统>>------------------------\n";

cout<<"******************************************************************************\n\n";

}

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<<"¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n";

}

//------------>建立链表信息

student*Information:

:

creat(void)

{//定义一个指向structstudent的结构体指针函数*creat()用来录入职工信息.

charch[N];n=0;//用来存放职工姓名

p1=p2=(student*)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元

cout<<"-------------<<请建立员工信息表,在姓名处键以#结束输入!

>>--------------"<

cout<<"姓名:

";

cin>>ch;

head=NULL;//给指针head赋初值

while(strcmp(ch,"#")!

=0)

{//调用字符比较函数strcmp()用来判断是否继续输入

p1=(student*)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元

strcpy(p1->name,ch);//将循环结构前面输入的姓名复制到结构体名为p1的数组name中

cout<<"性别:

";

cin>>p1->sex;

cout<<"编号:

";

cin>>p1->id;

while((p1->id)<0||(p1->id)>100000)//判断输入的编号是否有效(100000个)

{

cout<<"对不起您的输入错误!

请重新输入(>0<1000000):

";

cin>>p1->id;

}

cout<<"基本工资:

";

cin>>p1->paid[0];

while((p1->paid[0])<0||(p1->paid[0])>100000)//判断输入的分数是否有效(>=0<=100000)

{

cout<<"对不起您的输入错误!

请重新输入(>0<100000):

";

cin>>p1->paid[0];

}

cout<<"加班工资:

";

cin>>p1->paid[1];

while((p1->paid[1])<0||(p1->paid[1])>100000)//判断输入的分数是否有效(>=0<=100000)

{

cout<<"对不起您的输入错误!

请重新输入(>0<100000):

";

cin>>p1->paid[1];

}

cout<<"其他奖金:

";

cin>>p1->paid[2];

while((p1->paid[2])<0||(p1->paid[2])>100000)//判断输入的分数是否有效(>=0<=100000)

{

cout<<"对不起您的输入错误!

请重新输入(>0<100000):

";

cin>>p1->paid[2];

}

p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2];//计算总额

if(n==0)head=p1;//如果是输入第一组职工信息就将指针p1赋给指针head

elsep2->next=p1;//否则将p1赋给p2所指结构体的next指针

p2=p1;//将指针p1赋给指针p2

n++;//将职工人数n的值加1

cout<<"\n姓名:

";

cin>>ch;//将输入的姓名存放到字符数组ch中

}

p2->next=NULL;//将p2所指结构体的next指针重新赋空值

return(head);//将输入的第一组职工信息返回

}

//--------------->定义output()函数将职工的信息从头指针所指内容开始输出

voidInformation:

:

output(student*head)

{

system("cls");

if(head==NULL)cout<<"这是一个空表,请先输入员工信息!

\n";

else{

cout<<"-------------------------------------------------------------------------------\n";

cout<<"*职工工资信息表*\n";

cout<<"-------------------------------------------------------------------------------\n";

cout<<"|编号||姓名||性别||基本工资||加班工资||其他奖金||总额|\n";

cout<<"-------------------------------------------------------------------------------\n";

p1=head;//将头指针赋给p

do

{

cout<id

<name

<sex

<paid[0]

<paid[1]

<paid[2]

<total<

cout<<"-------------------------------------------------------------------------------\n";

p1=p1->next;//将下一组职工信息的next指针赋给p

}while(p1!

=NULL);//若指针p非空则继续,目的是把所有的职工信息都传给指针p然后输出.

}

}

//------------>统计职工人数的函数

intInformation:

:

count(structstudent*head)//定义函数count()统计职工总数

{

if(head==NULL)return(0);//若指针head为空返回值为0

elsereturn(1+count(head->next));//函数的递归调用

}

//----------->添加职工的成绩的函数

student*Information:

:

insert(student*head)

//插入新结点定义一个指向structstudent的结构体指针函数*insert()用来添加职工信息.

{

system("cls");

cout<<"\t----------------<<请输入新增员工信息>>----------------\n"<

p1=(student*)malloc(LEN);//使p1指向插入的新结点

cout<<"编号:

";

cin>>p1->id;

while((p1->id)<0||(p1->id)>100000)

{

cout<<"对不起您的输入错误!

请重新输入(>0<100000):

";

cin>>p1->id;//将输入的编号存放到p1所指结构体的数组id中

}

cout<<"姓名:

";

cin>>p1->name;//将输入的姓名存放到结构体名为p1的数组name中

cout<<"性别:

";

cin>>p1->sex;

cout<<"基本工资:

";

cin>>p1->paid[0];

while((p1->paid[0])<0|

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1