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

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

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

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

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

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

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||(p1->paid[0])>100000)

{

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

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

";

cin>>p1->paid[0];//将输入的基本工资存放到p1所指结构体的数组paid中

}

cout<<"加班工资:

";

cin>>p1->paid[1];

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

{

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

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

";

cin>>p1->paid[1];//将输入的加班工资存放到p1所指结构体的数组paid中

}

cout<<"其他奖金:

";

cin>>p1->paid[2];

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

{

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

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

";

cin>>p1->paid[2];//将输入的其他奖金存放到p1所指结构体的数组paid中

}

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

p2=head;//将头指针赋给p2

if(head==NULL)//若没调用次函数以前的头指针head为空

{

head=p1;p1->next=NULL;

}//则将p1赋给头指针head并将p1所指结构体成员指针next赋空值

else

{

while((p1->id>p2->id)&&(p2->next!

=NULL))

{

p3=p2;//p3指向原p2指向的结点

p2=p2->next;

}//p2后移一个结点

if(p1->id<=p2->id)

{

if(head==p2)

{

p1->next=head;

head=p1;

}//插入到第一个结点之前

else

{

p3->next=p1;

p1->next=p2;

}//插入到p3所指结点之后

}

else

{

p2->next=p1;

p1->next=NULL;

}//插入到尾结点之后

}

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

cout<<"\t----------------<<你输入的员工信息已经成功插入>>----------------"<

return(head);

}

//------------>删除职工信息

student*Information:

:

cancel(student*head,longid)//定义一个指向structstudent的结构体指针函数*delete()用来删除考生信息.

{

system("cls");

if(head==NULL)//若调用次函数以前的头指针head为空

{

return(head);

}

else

{

p1=head;//否则将头指针赋给p1

while(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->next;//如果head指针和p1指针相等则将下一个结点赋给指针head

else

p2->next=p1->next;//否则将p1所指结点赋给p2所指结点将要删除的职工信息跳过去

cout<<"删除编号为"<

n--;//将职工人数减1

}

return(head);//将头指针返回

}

}

/**************************修改职工数据**************************/

student*Information:

:

modify(student*head,longid)

{

system("cls");

cout<<"\t----------------<<请输入须修改的员工工资信息>>----------------\n"<

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

p1=head;//否则将头指针赋给p1

while(id!

=p1->id&&p1->next!

=NULL)

//寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空

{

p1=p1->next;//p2指向原p1指向的结点p1后移一个结点

}

if(id==p1->id)//如果要查找的职工编号是p1所指的职工编号

{

cout<<"你需要修改的员工信息如下:

\n";

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

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

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

cout<id

<name

<sex

<paid[0]

<paid[1]

<paid[2]

<total<

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

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||(p1->paid[0])>100000)

{

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

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

";

cin>>p1->paid[0];//将输入的基本工资存放到p1所指结构体的数组paid中

}

cout<<"加班工资:

";

cin>>p1->paid[1];

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

{

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

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

";

cin>>p1->paid[1];//将输入的加班工资存放到p1所指结构体的数组paid中

}

cout<<"其他奖金:

";

cin>>p1->paid[2];

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

{

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

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

";

cin>>p1->paid[2];//将输入的其他奖金存放到p1所指结构体的数组paid中

}

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

}

else

cout<<"需要修改的信息中没有编号为"<

getchar();

return(head);

}

//------------>查找职工信息

student*Information:

:

find(student*head,longid)

//定义一个指向structstudent的结构体指针函数*find()用来查找职工信息.

{

system("cls");

if(head==NULL)//若调用次函数以前的头指针head为空

{

cout<<"这是一个空表,请先输入员工信息!

\n";

return(head);

}

else

{

p1=head;//否则将头指针赋给p1

while(id!

=p1->id&&p1->next!

=NULL)

//寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空

{

p1=p1->next;//p2指向原p1指向的结点p1后移一个结点

}

if(id==p1->id)//如果要查找的职工编号是p1所指的职工编号

{

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

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

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

cout<id

<name

<sex

<paid[0]

<paid[1]

<paid[2]

<total<

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

}

else

cout<<"信息中没有编号为"<

return(head);

}

}

//------------定义paixu()函数将职工的工资总额从大到小排列并输出

voidInformation:

:

paixu(student*head)

{

system("cls");

inti,k,m=0,j;

student*p[N];//定义一个指向structstudent的结构体指针数组p

if(head!

=NULL)//如果头指针是空则继续

{m=count(head);

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

cout<<"*员工工资统计表*\n";

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

cout<<"|编号|

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

当前位置:首页 > 党团工作 > 入党转正申请

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

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