公司工资管理系统C源代码.doc

上传人:b****1 文档编号:234438 上传时间:2022-10-07 格式:DOC 页数:16 大小:56.50KB
下载 相关 举报
公司工资管理系统C源代码.doc_第1页
第1页 / 共16页
公司工资管理系统C源代码.doc_第2页
第2页 / 共16页
公司工资管理系统C源代码.doc_第3页
第3页 / 共16页
公司工资管理系统C源代码.doc_第4页
第4页 / 共16页
公司工资管理系统C源代码.doc_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

公司工资管理系统C源代码.doc

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

公司工资管理系统C源代码.doc

#include

#include

#include

#include

#include

#include

#defineNULL0

intconstN=20;

#defineLENsizeof(structstudent)

usingnamespacestd;

voidMenu();

voidPass();

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

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

structstudent

{

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

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

charzhiwu[N];//用来存放职务

charbumen[N];//用来存放所在部门

longid;//用来存放编号

floatpaid;//用来存放工资

inttotal;//用来存放总工资

structstudent*next;

};

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

classInformation

{

public:

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;};

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

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->bumen;

cout<<"请选择级别:

"<

cout<<"1.经理"<

cout<<"2.技术人员"<

cout<<"3.销售人员"<

cout<<"4.销售经理"<

intxuanze;

cin>>xuanze;

switch(xuanze)

{

case1:

floatwage1;

cout<<"请输入级别:

"<

cin>>p1->zhiwu;

cout<<"请输入经理的工资:

"<

cin>>wage1;

p1->paid=wage1;

break;

case2:

intworktime;

intwage2;

cout<<"请输入级别:

"<

cin>>p1->zhiwu;

cout<<"请输入技术人员的工作时间:

"<

cin>>worktime;

cout<<"请输入技术人员每小时的工资:

"<

cin>>wage2;

p1->paid=worktime*wage2;

break;

case3:

intwage3;

doubleticheng3;

cout<<"请输入级别:

"<

cin>>p1->zhiwu;

cout<<"请输入当月销售额:

"<

cin>>wage3;

cout<<"请输入提成比例:

"<

cin>>ticheng3;

p1->paid=wage3*ticheng3;

break;

case4:

intwage4;

doubleticheng4;

intgongzi;

cout<<"请输入级别:

"<

cin>>p1->zhiwu;

cout<<"请输入销售经理的固定工资:

"<

cin>>gongzi;

cout<<"请输入当月销售额:

"<

cin>>wage4;

cout<<"请输入提成比例:

"<

cin>>ticheng4;

p1->paid=gongzi+wage4*ticheng4;

break;

}

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<bumen<zhiwu<paid<

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)>

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

当前位置:首页 > 考试认证 > IT认证

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

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