小型公司工资管理系统(C)源代码
小型公司管理系统C++课程设计(含源代码)

C++程序设计课程设计报告课题:小型公司工资管理系统专业班级:学号:姓名:指导教师:评阅意见:评定成绩:指导老师签名:目录1.设计系统的目的意义 (1)2.系统需求、功能分析 (2)3. 数据结构表 (3)4。
数据测试表 (5)5. 运行和调试 (7)6。
课程心得体会 (16)参考书目 (17)附录 (18)课程设计报告内容:1、设计系统的目的意义本次课程设计所编辑的C++程序是为了建立“小型公司工资管理系统”。
通过对该系统的建立进一步掌握面向过程和面面相对象程序的设计的几本方法和编程技巧,巩固所学理论知识,是理论与实践相结合,提高分析问题、解决问题的能力。
具体一点主要是为了进一步熟悉C++中类的概念、类的继承、抽象类、虚函数、虚基类、多态和文件的输入/输出等内容的实现方式.了解系统开发的需求分析、类层次设计、模块分析、编码测试、模块组装与整体调试的全过程;逐步熟悉程序设计的方法,并养成良好的编程习惯。
2、系统需求、功能分析A、公司主要有四类雇员:经理、技术人员、销售人员、销售经理.要求储存雇员的编号、姓名、性别、所在部门、级别等信息,并进行工资计算.B、工资的计算方法(1)经理:领取固定月薪,固定月薪5000元;(2)技术人员:按小时领取月薪,工作时间*小时工资(80元/小时); (3)销售人员:按巩固销售额领取月薪,0。
33*销售额;(4)销售经理:既拿固定月薪也领取销售提成,0。
33*销售额+固定月薪(5000元)。
C、功能分析(1)添加功能:程序能够任意添加上述四类人员的记录,可提供选择界面供用户选择所要添加的人员类别,要求员工的编号要唯一,如果添加了重复编号的记录时,则提示数据添加重复并取消添加。
(2)查询功能:可根据编号、姓名等信息对已添加的记录进行查询,如果未找到,给出相应的提示信息,如果找到,则显示相应的记录信息;(3)显示功能:可显示当前系统中所有记录,每条记录占据一行。
(4)编辑功能:可根据查询结果对相应的记录进行修改,修改时注意编号的唯一性。
C++ 工资管理系统 源代码

#include<iostream>#include<string>#include<fstream>#include<iomanip>using namespace std; double sum,avarage;int amount=0;int ab=0,cd=0,ef=0; ofstream *file[50];struct xinxi{double jiben;double zhiwu;double gangwei;double yiliao;double gongji;double sum;double sum1;double avarage;struct xinxi *next;};class worker{public:string name;string ID;double sum;double avarage;xinxi sc1;class worker *next; };void luru(worker *head); void search1(worker *head); void search2(worker *head); void xianshi(worker *head); void xiugai(worker *head); void chazhao(worker *head); void shanchu(worker *head); void tianjia(worker *head); void tongji(worker *head); void display();void read(worker *head); void dakai(worker *head);int main(){system("color ff");int x;//bool flag2=0;/*do{do{cin>>x;if(x>=0&&x<=10)flag2=1;else{cout<<"~~~~~~~~~~~~指令错误!!!~~~~~~~~~~"<<endl;cout<<"请选择相应数字进行操作"<<endl;}}while(flag2==0)*/worker *head=new worker;head->next=NULL;while(1){display();cin>>x;if(x==1){cout<<"***************此刻进行职工数据的录入*****************\n";luru(head);cout<<"输入的职工信息为:\n";xianshi(head);display(); //break;}else if(x==2){cout<<"***************此刻进行职工数据的点窜******************\n";xiugai(head);display();//break; //按姓名点窜}else if(x==3){cout<<"***************此刻进行所有职工信息的显示*****************\n";xianshi(head);display();//break; //显示数据}else if(x==4){char z;cout<<"*****************此刻进行所有职工信息查找**************\n";cout<<"请选择查询方式\n";cout<<"(1).姓名查询方式(2).ID查询方式\n";cin>>z;while(z!='1'&&z!='2'){cout<<"**************指令错误********************\n";cout<<"(1).姓名查询方式(2).ID查询方式\n";cin>>z;}switch(z){case '1': search1(head);break;//按姓名查询case '2': search2(head);break;//按学号查询}display();// break;}else if(x==5){cout<<"***************此刻进行指定的职工信息的删除*****************\n";shanchu(head);xianshi(head);display();//break; //删除}else if(x==6){cout<<"****************此刻进行指定的职工信息的添加******************\n";tianjia(head);xianshi(head);display();break;//添加}else if(x==7){cout<<"**********************此刻进行指定的职工信息的统计***************\n";tongji(head);display();// break;}else if(x==8){cout<<"**********************此刻进行指定的职工信息的保留************\n";read(head);display();// break;}else if(x==9){cout<<"************************此刻进行指定的职工信息的翻开****************\n";dakai(head);display();// break;}else{cout<<" ╔═══════════════════════════╗\n";cout<<" ║您已退出职工办理系统, 谢谢您的使用! ║\n";cout<<" ╚═══════════════════════════╝\n";cout<<endl;exit(0);break;}}return 0;}void display(){cout<<" ╔═══════════════════════════╗"<<endl;cout<<" ║☆职工办理系统☆║"<<endl;cout<<" ║═══════════════════════════║"<<endl;cout<<" ║║"<<endl;cout<<" ║(1)职工数据的录入║"<<endl;cout<<" ║(2)职工数据的点窜║"<<endl;cout<<" ║(3)显示职工信息║"<<endl;cout<<" ║(4)查询职工信息║"<<endl;cout<<" ║--(1)按姓名查询║"<<endl;cout<<" ║--(2)按ID查询║"<<endl;cout<<" ║--统计总成就和平均成就║"<<endl;cout<<" ║(5)职工信息的删除║"<<endl;cout<<" ║(6)职工信息的添加║"<<endl;cout<<" ║(7)职工信息的统计║"<<endl;cout<<" ║(8)保留职工信息║"<<endl;cout<<" ║(9〕翻开职工信息║"<<endl;cout<<" ║退出程序║"<<endl;cout<<" ║║"<<endl;cout<<" ║═══════════════════════════║"<<endl;cout<<" ║注:请输入相应括号里的阿拉伯数字来执行相关操作!║"<<endl;cout<<" ║要保留数据请先成立好指定文件:║"<<endl;cout<<" ║(D:\\职工办理系统\\职工信息.txt) ║"<<endl;cout<<" ╟------------------------------------------------------╢"<<endl;cout<<" ║===================谢谢您的使用=======================║"<<endl;cout<<" ╚═══════════════════════════╝"<<endl;cout<<" →请选择相应的数字进行操作: "<<endl;}////////////////////////////////显示学生数据void xianshi(worker *head){worker *work=head->next;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;while(work!=NULL){cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;work=work->next;}system("pause");}void read(worker *head){char a;worker *work=head->next;cout<<"此刻保留输入职工数据,是否继续操作(y/n)";cin>>a;ofstream outfile("D:\\职工办理系统\\职工信息.txt",ios::out);if(! outfile){cout<<"翻开文件错误\n";cout<<"要保留数据请先成立好指定文件:D:\\职工办理系统\\职工信息.txt\n";exit(0);}while(a!='n'){while(work!=NULL){outfile<<"****************第"<<amount<<"个职工的数据:***************\n";outfile<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;outfile<<" 职工信息: \n" <<" | "<<setw(4)<<(*work).name<<" | "<<setw(4)<<(*work).ID<<" | "<<setw(4)<<(*work).scongji <<"|"<<setw(4)<<(*work).sc1.sum<<"|"<<setw(4)<<(*work).sc1.avarage<<"|"<< endl;amount++;work=work->next;}break;}cout<<"......成功将学生数据保留到<职工信息.txt>中! ";outfile.close();}void dakai(worker *head){worker *work=head->next;ofstream ofile("D:\\职工办理系统\\职工信息.txt",ios::out);work=work->next;}void luru(worker *head){char c;int j=0;worker *p=head;file[j]=new ofstream("D:\\职工办理系统\\职工信息.txt",ios::app);do{worker *work=new worker;cout<<"请输入姓名:"<<setw(10);cin>>(*work).name;cout<<"请输入ID:"<<setw(10);cin>>(*work).ID;cout<<"请输入底子工资:"<<setw(2);cin>>(*work).sc1.jiben;cout<<"请输入职务工资:"<<setw(2);cin>>(*work).sc1.zhiwu;cout<<"请输入岗位津贴:"<<setw(2);cin>>(*work).sc1.gangwei;cout<<"请输入医疗保险:"<<setw(2);cin>>(*work).sc1.yiliao;cout<<"请输入公积金:"<<setw(2);cin>>(*work).sc1.gongji;(*work).sc1.sum=(*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1.zhiw u+(*work).sc1.jiben;(*work).sc1.avarage=((*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1. zhiwu+(*work).sc1.jiben)/5;(*work).sc1.sum1=(*work).sc1.gangwei+(*work).sc1.zhiwu+(*work).sc1.jiben;if((*work).sc1.sum1>=2000) ab++;if((*work).sc1.sum1>=1500&&(*work).sc1.sum1<2000) cd++;if((*work).sc1.sum1>=1000&&(*work).sc1.sum1<1500) ef++;work->next=p->next;p->next=work;amount++;cout<<"数据录入成功,想继续录入吗(y/n)"; cin>>c;p=p->next;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"数据录入成功,想继续录入吗(y/n)";cin>>c;}}while(c=='y');j++;cout<<"输入了"<<amount<<"个职工的信息."<<endl;}void search1(worker *head){char c;string name;do{worker*work=head->next;bool flag=0;cout<<"请输入要查找的职工的姓名:";cin>>name;do{if(work!=NULL&&name==(*work).name){flag=1;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" |"<<setw(4)<<(*work).sc1.sum;cout<<" |"<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;}work=work->next;}while(work!=NULL);if(flag==0)cout<<"对不起!您要查询的职工不存在"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;}}while(c=='y');}void search2(worker *head){char c;string ID;do{worker *work=head->next;int flag=0;cout<<"请输入要查找职工的ID";cin>>ID;do{if(work!=NULL&&ID==(*work).ID){flag=1;cout<<"你要查询的学生是"<<work->name<<endl;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;}work=work->next;}while(work!=NULL);if(flag==0)cout<<"对不起!您要查询的职工不存在"<<endl;cout<<"您想继续查询吗(y/n)";cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续查询吗(y/n)"<<endl;cin>>c;}}while(c=='y');}void xiugai(worker *head){string name;char c;do{bool flag2=0;worker *work=head->next;xinxi sc1;cout<<"请输入你要点窜的职工的姓名:";cin>>name;do{if(name==(*work).name){flag2=1;cout<<"请输入新的底子工资:";cin>>sc1.jiben;cout<<"请输入新的职务工资:";cin>>sc1.zhiwu;cout<<"请输入新的岗位津贴:";cin>>sc1.gangwei;cout<<"请输入新的医疗保险:";cin>>sc1.yiliao;cout<<"请输入新的公积金:";cin>>sc1.gongji;(*work).sc1.jiben=sc1.jiben;(*work).sc1.zhiwu=sc1.zhiwu;(*work).sc1.gangwei=sc1.gangwei;(*work).sc1.sum=(*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.jiben+(*work).sc1. yiliao+(*work).sc1.zhiwu;(*work).sc1.avarage=((*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.jiben+(*work). sc1.yiliao+(*work).sc1.zhiwu)/5;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;cout<<"数据点窜成功......";break;}work=work->next;}while(work!=NULL);if(flag2==0){cout<<"对不起!您要点窜的职工不存在!请查抄从头输入"<<endl; }cout<<"想继续点窜吗(y/n)";cin>>c;if(c!='y'&&c!='n'){cout<<"指令错误!请从头输入<y/n>";cin>>c;}}while(c=='y');}void shanchu(worker *head){char c;string no;do{int flag=0;cout<<"请输入要删除的职工ID";cin>>no;worker *p,*q;q=head;while(q->next!=NULL&&q->next->ID!=no)q=q->next;if(q->next!=NULL){flag=1;p=q->next;q->next=q->next->next;amount--;free(p);cout<<"......成功删除! ";}if(flag==0)cout<<"对不起!您要删除的职工不存在"<<endl;cout<<"您想继续删除吗(y/n)";cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续删除吗(y/n)";cin>>c;}}while(c=='y');}void tongji(worker *head){char c;string name;do{worker *work=head->next;bool flag=0;cout<<"----总工资和平均工资的计算------"<<endl;cout<<"请输入要统计职工的姓名";cin>>name;do{if(work!=NULL&&name==(*work).name){flag=1;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;cout<<"超过2000的百分比:"<<endl;cout<<(ab*100)/amount<<"%"<<endl;cout<<"小于2000,大于等于1500"<<endl;cout<<(cd*100)/amount<<"%"<<endl;cout<<"小于1500,大于等于1000"<<endl;cout<<(ef*100)/amount<<"%"<<endl;}work=work->next;}while(work!=NULL);if(flag==0)cout<<"对不起!您要查询的职工不存在"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;}} while(c=='y');}void tianjia(worker *head){char c;int j=0;worker *p=head;file[j]=new ofstream("D:\\职工办理系统\\职工信息.txt",ios::app);do{worker *work=new worker;cout<<"请输入姓名:"<<setw(10);cin>>(*work).name;cout<<"请输入ID:"<<setw(10);cin>>(*work).ID;cout<<"请输入底子工资:"<<setw(2);cin>>(*work).sc1.jiben;cout<<"请输入职务工资:"<<setw(2);cin>>(*work).sc1.zhiwu;cout<<"请输入岗位津贴:"<<setw(2);cin>>(*work).sc1.gangwei;cout<<"请输入医疗保险:"<<setw(2);cin>>(*work).sc1.yiliao;cout<<"请输入公积金:"<<setw(2);cin>>(*work).sc1.gongji;(*work).sc1.sum=(*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1.zhiwu+(*work).sc1.jiben;(*work).sc1.avarage=((*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1. zhiwu+(*work).sc1.jiben)/5;(*work).sc1.sum1=(*work).sc1.gangwei+(*work).sc1.zhiwu+(*work).sc1.jiben;if((*work).sc1.sum1>=2000) ab++;if((*work).sc1.sum1>=1500&&(*work).sc1.sum1<2000) cd++;if((*work).sc1.sum1>=1000&&(*work).sc1.sum1<1500) ef++;work->next=p->next;p->next=work;amount++;cout<<"数据添加成功,想继续添加吗(y/n)"; cin>>c;p=p->next;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"数据添加成功,想继续添加吗(y/n)";cin>>c;}}while(c=='y');j++;cout<<"输入了"<<amount<<"个职工的信息."<<endl;}。
c语言课程设计职工工资管理系统源代码

绝对可以完美运行,下面有运行图片#include<stdio.h> //调用库函数#include<string.h> //字符串处理#include<conio.h> //控制台输入输出#include<stdlib.h> //定义杂项函数及内存分配函数#define N 2 //宏定义以3代替N/******************************************************************************函数声明*******************************************************************************/ void enter();int menu();void input();void output();void search();void search_employeeid();void search_name();void edit();void array();void array_basesalary();void array_postwage();void array_totalwage();void statistics();void save();void load();/******************************************************************************职工类型定义*******************************************************************************/ struct employee{char employeeid[10];char name[10];char sex[10];int age;float basesalary;float postwage;float totalwage;};/******************************************************************************职工变量定义******************************************************************************/ struct employee emp[N];struct employee replace;struct employee *p=emp;/*****************************************************************************系统主函数******************************************************************************/ void main(){int c;while(1){printf(" \n\n\n\n");printf(" 欢迎进入职工工资管理系统\n\n\n");printf(" 1 进入管理系统\n\n");printf(" 0 退出\n\n");printf(" \n\n\n\n");printf(" 请输入你选择:\n");scanf("%d",&c);switch(c){case 1:enter();break;case 0:printf(" 谢谢使用!\n");exit(0);}}}/***************************************************************************** 功能:登陆函数,进行密码验证*****************************************************************************/ void enter(){char q;char key[10],password[10]="china";int k=1,i;printf(" 请输入密码:\n");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}while(k<=3){if(strncmp(key,password,5)==0){while(1){int a;//system("cls");a=menu();switch(a){case 1:input();break;case 2:output();break;case 3:search();break;case 4:edit();break;case 5:array();break;case 6:load();statistics();break;case 0:printf("\n\n 谢谢使用!\n\n\n\n");save();exit(0);}}}else{k++;printf(" 输入密码错误!请再次输入:");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}if(k>2){if(strncmp(password,key,5)==0)continue;else{printf(" 输入密码错误三次,系统将自动退出!\n");exit(0);}}}}}/************************************************************************功能: 主菜单函数参数:a类型:int说明: 变量返回值: a************************************************************************/int menu(){int a ;printf("\n\n");printf("|*****************欢迎进入职工工资管理系统************************|\n");printf("| |\n");printf("| |\n");printf("| 1 职工信息输入|\n");printf("| |\n");printf("| 2 职工信息输出|\n");printf("| |\n");printf("| 3 职工信息查询|\n");printf("| |\n");printf("| 4 职工信息修改|\n");printf("| |\n");printf("| 5 工资排序|\n");printf("| |\n");printf("| 6 工资统计|\n");printf("| |\n");printf("| 0 退出|\n");printf("| |\n");printf("| |\n");printf("|*****************************************************************|\n");printf("\n\n");printf(" 请输入你所选择的选项:");scanf("%d",&a);while(a>6||a<0){printf(" error!\n");printf(" 请重新输入你所选择的选项:");scanf("%d",&a);}return a;}/********************************************************************************* ***功能:职工信息输入********************************************************************************** ***/void input(){int c;p=emp;printf(" 进入职工信息输入模块\n\n\n");for(c=0;c<N;c++,p++){p[c].totalwage=p[c].basesalary+p[c].postwage;printf(" 请输入第%d个职工信息:\n\n",c+1);printf(" 请输入职工号:\n");scanf("%s",p->employeeid);if(strcmp(p->employeeid,"0")!=0){printf(" 请输入职工姓名:\n");scanf("%s",p->name);printf(" 请输入职工性别: \n");scanf("%s",&p->sex);printf(" 请输入职工年龄: \n");scanf("%d",&p->age);printf(" 请输入职工基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入职工岗位工资:\n");scanf("%f",&p->postwage);printf(" 职工信息输入完成!\n\n");}elsereturn;}save();}/******************************************************************************* 功能:职工信息输出********************************************************************************/ void output(){int j;load();p=emp;printf(" 进入职工信息输出模块\n\n\n");printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("-------------------------------------------------------------------------------\n");for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");}printf("\n\n 职工信息输出完成!\n\n");getchar();}/******************************************************************************功能:职工信息查询******************************************************************************/ void search(){int j;while(1){printf("*********************职工信息查询*********************\n\n\n");printf(" 1 按职工号查询\n");printf(" 2 按职工姓名查询\n");printf(" 0 退出该项操作\n");printf("\n\n");while(1){printf(" 请输入你的选择\n");scanf("%d",&j);if(j>=0&&j<=2){switch(j){case 1:search_employeeid();break;case 2:search_name();break;case 0:return;}}else{printf(" 输入错误!\n\n");printf(" 请再次输入你的选择: \n\n");}}}}/******************************************************************************* 功能:按职工号查询函数*******************************************************************************/ void search_employeeid(){char employeeid[10];int k,j;p=emp;printf("*********************按职工号查询职工信息*****************************\n\n\n\n");printf(" 请输入要查询职工的职工号:\n\n");scanf("%s",employeeid);for(k=0;k<N;k++){if(strcmp(employeeid,p->employeeid)==0){j=k;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found\n");return;}}}/*****************************************************************************功能:按职工姓名查询函数*****************************************************************************/ void search_name(){char name[10];int flog=0;int f,j;p=emp;printf("******************************按职工姓名查询职工信息***********************\n\n\n");printf(" 请输入要查询职工的姓名:\n\n");scanf("%s",name);for(f=0;f<N;f++,p++){if(strcmp(name,p->name)==0){j=f;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found \n\n");return;}}getchar();}/*******************************************************************************功能:职工信息修改函数*******************************************************************************/ void edit(){char e[10];int g=0,j;char flog;p=emp;printf(" 请输入你要修改职工的职工号:\n");scanf("%s",e);for(g=0;g<N;g++){// if(*e==p[g].employeeid)if(strcmp(e,p->employeeid)==0){j=g;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p[j].sex ,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");printf(" 是否要修改该职工信息?y(是)or n(否)?\n\n");getchar();scanf("%c",&flog);if(flog == 'y'){printf(" 请输入新姓名:\n");scanf("%s",p->name);printf(" 请输入性别:\n");scanf("%s",&p->sex);printf(" 请输入年龄:\n");scanf("%d",&p->age);printf(" 请输入基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入岗位工资:\n");scanf("%f",&p->postwage);printf(" 修改职工信息成功!\n\n");}if(flog == 'n'){printf(" 退出该项操作!\n\n");return;}save();}if(g==N){printf(" not found \n\n\n");return;}}}/************************************************************************ 功能:职工工资排列函数************************************************************************/ void array(){int j;while(1){printf("*************************工资排序*********************\n\n");printf(" 1 按基本工资排序\n\n");printf(" 2 按岗位工资排序\n\n");printf(" 3 按总工资排列\n\n");printf(" 0 退出\n\n");printf("\n\n\n");while(1){printf(" 请输入你的选择:\n\n");scanf("%d",&j);if(j>=0&&j<=3){switch(j){case 1:array_basesalary();break;case 2:array_postwage();break;case 3:array_totalwage();break;case 0:return;}}else{printf(" 输入错误!\n\n\n");printf(" 请再次输入你的选择:\n\n");}}}}/**************************************************************************功能:按基本工资排列(选择法)***************************************************************************/void array_basesalary(){int i,j,k;p=emp;for(i=0;i<N-1;i++){k=i;for(j=i+1;j<N;j++){if(p[k].basesalary<p[j].basesalary)k=j;}if(k!=i){replace=emp[k];emp[k]=emp[i];emp[i]=replace;}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按岗位工资排列(冒泡法)*************************************************************************/void array_postwage(){int i,j;p=emp;for(i=0;i<N;i++){for(j=0;j<N-i;j++){if(p[j].postwage<p[j+1].postwage){replace=emp[j];emp[j]=emp[j+1];emp[j+1]=replace;}}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按总工资排列(插入法)************************************************************************/void array_totalwage(){int i,j;p=emp;for(i=1;i<N;i++){replace=emp[i];for(j=i-1;j>=0&&p[i].totalwage>p[i].totalwage;j--){emp[j+1]=emp[j];emp[j+1]=replace;}}for(j=N-1;j>=0;j--){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别| 年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/*************************************************************************功能:工资统计函数**************************************************************************/void statistics(){int z,a=0,b=0,c=0;p=emp;for(z=0;z<N;z++){if(p[z].totalwage>3000){a++;continue;}if(p[z].totalwage>=2000&&p[z].totalwage<=3000){b++;continue;}if(p[z].totalwage<=2000&&p[z].totalwage>0){c++;continue;}}printf(" 总工资在3000元以上的职工人数有:%d\n\n",a);printf(" 总工资在2000元至3000元的职工人数有:%d\n\n",b);printf(" 总工资在2000元以下的职工人数有:%d\n\n",c);getchar();}/*************************************************************************** 功能:导出函数***************************************************************************/ void save(){int k;FILE *fp;p=emp;if((fp=fopen("emp_list","wb"))==NULL){printf(" Create file error!\n");return;}for(k=0;k<N;k++,p++){if(fwrite(p,sizeof(struct employee),1,fp)!=1){printf(" file save error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}/***********************************************************************功能:导入函数***********************************************************************/ void load(){int l;FILE *fp;p=emp;if((fp=fopen("emp_list","rb"))==NULL){printf(" Create file error!\n");exit(0);}for(l=0;l<N;l++,p++){if(fread(p,sizeof(struct employee),1,fp)!=1){printf(" file read error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}下面是实验结果。
用C++编程——小型公司工资管理系统

#include <iostream>#include <string>#include <iomanip>#include <fstream>using namespace std;const int n=2;class Employee{protected:int num;string name;int age;char sex;double salary;public:Employee(int n=0,int a=0,double sa=0){num=n;age=a;salary=sa;} virtual void input();virtual void print(){};virtual void txtout(){} ;int funnum(){return num;}string funname(){return name;}};void Employee::input(){cout<<"编号:";cin>>num;cout<<"其姓名:";cin>>name;cout<<"性别(w/m):";cin>>sex;cout<<"年龄:";cin>>age;}class Technician:public Employee{protected:int hours;int hourlypay;public:Technician(int hp=100){hourlypay=hp;}virtual void input();virtual double pay(){return (salary=hours*hourlypay);}virtual void print();virtual void txtout();};void Technician::input()cout<<"技术员的";Employee::input();cout<<"工作时间:";cin>>hours;}class Manager:public Employee{public:Manager(double sa=8000){salary=sa;}virtual void input();virtual void print();virtual void txtout();};void Manager::input(){cout<<"经理的";Employee::input();}class Salesman:public Employee{protected:double commrate;//提成int Smnum;//所属经理的编号double sales;//销售额public:Salesman(double com=0.04){commrate=com;}virtual void input();virtual double pay(){return (salary=sales*commrate);} virtual void print();virtual void txtout();int funnum1(){return Smnum;}double funsales(){return sales;}};void Salesman::input(){cout<<"销售员的";Employee::input();cout<<"销售额:";cin>>sales;cout<<"所属销售经理的编号:";cin>>Smnum;class Salesmanager:public Employee{protected:double basepay,sumsales,commrate;//底薪,销售总额,提成public:Salesmanager(double base=5000,double com=0.005){basepay=base;commrate=com;}virtual void input();virtual void print();virtual void print1();virtual void pay();virtual void shujutongji();virtual void txtout();};Technician tec[n];Manager man[n];Salesman sal[2*n];Salesmanager sma[n];//定义全局变量void Salesmanager::input(){cout<<"销售经理的";Employee::input();}void Salesmanager::pay(){for(int i=0;i<n;i++){sma[i].sumsales=0;for(int j=0;j<2*n;j++){if(sal[j].funnum1()==sma[j].num)sma[j].sumsales=sma[j].sumsales+sal[j].funsales();}sma[i].salary=basepay+sma[i].sumsales*commrate;}}void Salesmanager::print(){for(int i=0;i<n;i++){sma[i].sumsales=0;cout<<"职工编号为"<<sma[i].num<<"销售经理"<<sma[i].name<<"下属销售员的业绩为:"<<endl;cout<<"┌─────┬─────┬─────┐"<<endl;cout<<"│ 职工号│ 姓名│ 销售额│"<<endl;for(int j=0;j<2*n;j++)if(sal[j].funnum1()==sma[i].num){sma[i].sumsales=sma[i].sumsales+sal[j].funsales();cout<<"├─────┼─────┼─────┤"<<endl;cout<<"│"<<setw(10)<<sal[j].funnum()<<"│"<<setw(10)<<sal[j ].funname()<<"│"<<setw(10)<<sal[j].funsales()<<"│"<<endl;}cout<<"├─────┼─────┴─────┤"<<endl;cout<<"│销售额总计│"<<setw(22)<<sma[i].sumsales<<"│"<<endl;cout<<"└─────┴───────────┘"<<endl;}}void Salesmanager::shujutongji(){for(int i=0;i<n;i++){sma[i].sumsales=0;for(int j=0;j<2*n;j++){if(sal[j].funnum1()==sma[i].num)sma[i].sumsales+=sal[j].funsales();}sma[i].salary=basepay+sma[i].sumsales*commrate;}for(int k=0;k<n-1;k++)for(int m=k+1;m<n;m++)if(sma[k].salary<sma[m].salary){Salesmanager sma1;sma1=sma[k];sma[k]=sma[m];sma[m]=sma1;}cout<<"销售经理按工资排序为:"<<endl;cout<<"┌────┬────┬────┬────┬────┐"<< endl;cout<<"│职工号│姓名│性别│年龄│工资│"<<endl;for(int e=0;e<n;e++){<<endl;cout<<"│"<<setw(8)<<sma[e].num<<"│"<<setw(8)<<sma[e].name< <"│"<<setw(8)<<sma[e].sex<<"│"<<setw(8)<<sma[e].age<<"│"<<setw(8)<<sm a[e].salary<<"│"<<endl;}cout<<"└────┴────┴────┴────┴────┘"<< endl;}void Technician::print(){cout<<"┌────┬────┬────┬────┬────┐"<<endl; cout<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│"<<endl;for(int i=0;i<n;i++){cout<<"├────┼────┼────┼────┼────┤"<<en dl;cout<<"│"<<setw(8)<<tec[i].num<<"│"<<setw(8)<<tec[i].name<<"│"<<setw(8)<<tec[i].sex<<"│"<<setw(8)<<tec[i].age<<"│"<<setw(8)<<tec[i] .pay()<<"│"<<endl;}cout<<"└────┴────┴────┴────┴────┘"<<endl; }void Manager::print(){cout<<"┌────┬────┬────┬────┬────┐"<<endl; cout<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│"<<endl;for(int i=0;i<n;i++){cout<<"├────┼────┼────┼────┼────┤"<<en dl;cout<<"│"<<setw(8)<<man[i].num<<"│"<<setw(8)<<man[i].name<<"│"<<setw(8)<<man[i].sex<<"│"<<setw(8)<<man[i].age<<"│"<<setw(8)<<man[i] .salary<<"│"<<endl;}cout<<"└────┴────┴────┴────┴────┘"<<endl; }void Salesman::print(){────┐"<<endl;cout<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│ 所属部门经理编号│"<<endl;for(int i=0;i<2*n;i++){cout<<"├────┼────┼────┼────┼────┼─────────┤"<<endl;cout<<"│"<<setw(8)<<sal[i].num<<"│"<<setw(8)<<sal[i].name<<"│"<<setw(8)<<sal[i].sex<<"│"<<setw(8)<<sal[i].age<<"│"<<setw(8)<<sal[i] .pay()<<"│"<<setw(18)<<sal[i].funnum1()<<"│"<<endl;}cout<<"└────┴────┴────┴────┴────┴─────────┘"<<endl;}void Salesmanager::print1()//{cout<<"┌────┬────┬────┬────┬────┐"<<endl; cout<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│"<<endl;for(int i=0;i<n;i++){cout<<"├────┼────┼────┼────┼────┤"<<en dl;cout<<"│"<<setw(8)<<sma[i].num<<"│"<<setw(8)<<sma[i].name<<"│"<<setw(8)<<sma[i].sex<<"│"<<setw(8)<<sma[i].age<<"│"<<setw(8)<<sma[i] .salary<<"│"<<endl;}cout<<"└────┴────┴────┴────┴────┘"<<endl; }void Technician::txtout()//技术员数据备份{ofstream outfile("d:\output.txt",ios::app);if(!outfile){cout<<"备份失败!"<<endl;}outfile<<"************* 公司职员信息备份 ****************"<<endl; outfile<<"*****技术员信息*****"<<endl;outfile<<"┌────┬────┬────┬────┬────┐"<<endl ;outfile<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│"<<endl;for(int i=0;i<n;i++){outfile<<"├────┼────┼────┼────┼────┤"< <endl;outfile<<"│"<<setw(8)<<tec[i].num<<"│"<<setw(8)<<tec[i].name<< "│"<<setw(8)<<tec[i].sex<<"│"<<setw(8)<<tec[i].age<<"│"<<setw(8)<<tec[i] .pay()<<"│"<<endl;}outfile<<"└────┴────┴────┴────┴────┘"<<endl ;outfile<<"********************************************"<<endl;}void Manager::txtout()//经理数据备份{ofstream outfile("d:\output.txt",ios::app);if(!outfile){cout<<"备份失败!"<<endl;}outfile<<"*****经理信息*****"<<endl;outfile<<"┌────┬────┬────┬────┬────┐"<<endl ;outfile<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│"<<endl;for(int i=0;i<n;i++){outfile<<"├────┼────┼────┼────┼────┤"< <endl;outfile<<"│"<<setw(8)<<man[i].num<<"│"<<setw(8)<<man[i].name<< "│"<<setw(8)<<man[i].sex<<"│"<<setw(8)<<man[i].age<<"│"<<setw(8)<<man[i] .salary<<"│"<<endl;}outfile<<"└────┴────┴────┴────┴────┘"<<endl ;outfile<<"********************************************"<<endl;}void Salesmanager::txtout()//销售经理数据备份{ofstream outfile("d:\output.txt",ios::app);if(!outfile){cout<<"备份失败!"<<endl;}outfile<<"*****销售经理信息*****"<<endl;outfile<<"┌────┬────┬────┬────┬────┐"<<endl ;outfile<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│"<<endl;for(int i=0;i<n;i++){outfile<<"├────┼────┼────┼────┼────┤"< <endl;outfile<<"│"<<setw(8)<<sma[i].num<<"│"<<setw(8)<<sma[i].name<< "│"<<setw(8)<<sma[i].sex<<"│"<<setw(8)<<sma[i].age<<"│"<<setw(8)<<sma[i] .salary<<"│"<<endl;}outfile<<"└────┴────┴────┴────┴────┘"<<endl ;outfile<<"********************************************"<<endl;}void Salesman::txtout()//销售员数据备份{ofstream outfile("d:\output.txt",ios::app);if(!outfile){cout<<"备份失败!"<<endl;}outfile<<"*****销售员信息*****"<<endl;outfile<<"┌────┬────┬────┬────┬────┬─────────┐"<<endl;outfile<<"│ 职工号│ 姓名│ 性别│ 年龄│ 工资│ 所属部门经理编号│"<<endl;for(int i=0;i<2*n;i++){outfile<<"├────┼────┼────┼────┼────┼─────────┤"<<endl;outfile<<"│"<<setw(8)<<sal[i].num<<"│"<<setw(8)<<sal[i].name<< "│"<<setw(8)<<sal[i].sex<<"│"<<setw(8)<<sal[i].age<<"│"<<setw(8)<<sal[i] .pay()<<"│"<<setw(18)<<sal[i].funnum1()<<"│"<<endl;}outfile<<"└────┴────┴────┴────┴────┴─────────┘"<<endl;outfile<<"********************************************"<<endl;}int main(){for(int i=0;;i++){int j;cout<<"★★小型公司工资管理系统★★"<<endl;cout<<"┌─────────────┐"<<endl;cout<<"│请选择您所需的操作│"<<endl;cout<<"│ 数据输入:1,并按回车键│"<<endl;cout<<"│ 数据统计:2,并按回车键│"<<endl;cout<<"│ 数据打印:3,并按回车键│"<<endl;cout<<"│ 数据备份:4,并按回车键│"<<e ndl;cout<<"│ 退出系统:5,并按回车键│"<<endl;cout<<"└─────────────┘"<<endl;cout<<"请输入一个操作: ";cin>>j;cout<<endl;switch(j){case 1:{for(int i=0;i<n;i++){tec[i].input();cout<<endl;};cout<<"---------------------------"<<endl;for(i=0;i<n;i++){man[i].input();cout<<endl;};cout<<"---------------------------"<<endl;for(i=0;i<2*n;i++){sal[i].input();cout<<endl;};cout<<"---------------------------"<<endl;for(i=0;i<n;i++){sma[i].input();cout<<endl;}; };break;case 2:{Salesmanager sma1;sma1.print();sma1.shujutongji();};break;case 3:{cout<<" 请等待......"<<endl;cout<<"职工基本情况一览表如下"<<endl;cout<<endl;cout<<"技术员"<<endl;{Technician tec1;tec1.print();cout<<endl;};cout<<"---------------------------"<<endl;cout<<"经理"<<endl;{Manager man1;man1.print();cout<<endl;};cout<<"---------------------------"<<endl;cout<<"销售经理"<<endl;{Salesmanager sma1;sma1.print1();cout<<endl;};cout<<"---------------------------"<<endl;cout<<"销售员"<<endl;{Salesman sal1;sal1.print();cout<<endl;};cout<<"---------------------------"<<endl;};break;case 4:{cout<<"数据正在备份,请等待......"<<endl;Technician tec1;tec1.txtout();Manager man1;man1.txtout();Salesmanager sma1;sma1.txtout();Salesman sal1;sal1.txtout();cout<<"数据备份完成!"<<endl;};break;case 5:exit(1);break;default : cout<<"输入有误,请重新输入。
工资管理系统源代码c

cerr << "open error!" << endl;
exit(0);
}
int b;
cout << "请输入你要教师兼职领导的个数:";
cin >> b;
for (i = 0; i < b; i++) {
{
ofstream outfile("教师.txt", ios::app);
if (!outfile) {
cerr << "open error!" << endl;
exit(0);
}
int b;
cout << "请选择你要录入教师的个数:";
cin >> time;
while(time<=0)
{
cout<<"请重新输入课时大于0的数:"<<endl;
cin>>time;
}
cin >> b;
for (i = 0; i < b; i++) {
t[i].display1();
cout<<"是否保存信息(y(Y)/n(N))"<<endl;
char c;
cin>>c;
exit(0);
}
int b;
cout << "请输入你要录入领导的个数:";
C 工资管理系统源程序

#include "stdafx.h"#include "iostream"#include "string"#include "list"#include "cassert"using namespace std;/*编号、姓名、部门、应付工资、保险、税金、实付工资。
其中实付工资由公式计算得到:实付工资=应付工资- 保险- 税金*/struct employee{string m_num;//编号string m_name;//姓名string m_dep;//部门double m_salary;//应付工资double m_insurance;//保险double m_tax;//税金};/*(1)录入:输入职工数据,其中“实付工资”通过计算得到;(2)删除:删除指定的职工信息(输入姓名,若找到则删除该信息)(3) 修改:允许对已经录入的数据重新进行编辑、修改;(4) 显示:显示全体职工数据;(5)查询:a. 输入职工姓名,显示该职工的全部数据;b. 输入某部门值,显示该部门职工的数据、工资总额、平均工资。
(6) 退出程序。
*/list<employee> emps;int _tmain(int argc, _TCHAR* argv[]){void print(const employee &e);void input();void del();void mod();void show_all();void show_name();void show_dep();cout<<"简易职工薪水管理程序by 做他\n";// delete this linecout<<"版权没有请随意复制或修改任何代码\n";//delete this linecout<<"请选择操作:1.录入2.删除3.修改4.查询5.显示所有员工6.退出:";int choose=0;cin>>choose;assert(!cin.fail());while (choose!=6){if (choose==1) input();if (choose==2) del();if (choose==3) mod();if (choose==4){int choice=0;cout<<"请选择操作1.按姓名查询2.按部门查询3.退出:";cin>>choice;if (choice==1) show_name();if (choice==2) show_dep();if (choice==3){cout<<"请选择操作:1.录入2.删除3.修改4.查询5.显示所有员工6.退出:";cin>>choose;assert(!cin.fail());continue;}}if (choose==5) show_all();cout<<"请选择操作:1.录入2.删除3.修改4.查询5.显示所有员工6.退出:"; cin>>choose;assert(!cin.fail());}return 0;}void print(const employee &e){cout<<"编号:"<<e.m_num<<endl;cout<<"姓名:"<<e.m_name<<endl;cout<<"部门:"<<e.m_dep<<endl;cout<<"保险:"<<e.m_insurance<<endl;cout<<"税金:"<<e.m_tax<<endl;cout<<"应付工资:"<<e.m_salary<<endl;cout<<"实付工资:"<<e.m_salary-e.m_insurance-e.m_tax<<endl; }void input(){string num,name,dep;double salary,ins,tax;cout<<"请输入员工编号:";cin>>num;cout<<"请输入员工姓名:";cin>>name;cout<<"请输入员工部门:";cin>>dep;cout<<"请输入员工保险:";cin>>ins;assert(!cin.fail());cout<<"请输入员工税金:";cin>>tax;assert(!cin.fail());cout<<"请输入员工应付工资:";cin>>salary;assert(!cin.fail());employee temp;temp.m_dep=dep;temp.m_insurance=ins;temp.m_name=name;temp.m_num=num;temp.m_salary=salary;temp.m_tax=tax;emps.push_back(temp);cout<<"员工录入操作完毕.\n";}void del(){if (emps.size()==0){cout<<"没有员工记录.\n";return;}string name;bool isfind=false;cout<<"请输入要删除的员工姓名:";cin>>name;list<employee>::iterator iter;for (iter=emps.begin();iter!=emps.end();iter++){if (iter->m_name==name){isfind=true;emps.erase(iter);cout<<"姓名为\""<<name<<"\"的员工记录已删除.\n";return;}}if (!isfind){cout<<"没有找到姓名为\""<<name<<"\"的员工.\n"; return;}}void mod(){if (emps.size()==0){cout<<"员工记录为空.\n";return;}bool isfind=false;string name;cout<<"请输入要修改的员工姓名:";cin>>name;list<employee>::iterator iter;for (iter=emps.begin();iter!=emps.end();iter++){if (iter->m_name==name){isfind=true;cout<<"姓名为\""<<name<<"\"的员工记录已找到.\n"; break;}}if (isfind){string num,name,dep;double tax,ins,salary;print(*iter);cout<<endl;cout<<"请输入新的员工编号:";cin>>num;cout<<"请输入新的员工姓名:";cin>>name;cout<<"请输入新的员工部门:";cin>>dep;cout<<"请输入新的员工保险:";cin>>ins;assert(!cin.fail());cout<<"请输入新的员工税金:";cin>>tax;assert(!cin.fail());cout<<"请输入新的员工工资:";cin>>salary;assert(!cin.fail());iter->m_dep=dep;iter->m_insurance=ins;iter->m_name=name;iter->m_num=num;iter->m_salary=salary;iter->m_tax=tax;cout<<"1 员工记录被成功修改.\n";}else{cout<<"没有找到姓名为\""<<name<<"\"的员工记录.\n"; }}void show_all(){if (emps.size()==0){cout<<"员工记录为空.\n";return;}cout<<"显示全体员工数据:\n";cout<<"--------------------\n";list<employee>::iterator iter;for(iter=emps.begin();iter!=emps.end();iter++){cout<<endl;print(*iter);cout<<endl;}cout<<"--------------------\n";}void show_name(){if (emps.size()==0){cout<<"员工记录为空.\n";return;}bool isfind=false;string name;cout<<"请输入要查询的员工姓名:";cin>>name;list<employee>::iterator iter;for(iter=emps.begin();iter!=emps.end();iter++){if (iter->m_name==name){isfind=true;cout<<"姓名为\""<<name<<"\"的员工记录已找到.\n";print(*iter);break;}}if (!isfind){cout<<"没有找到姓名为\""<<name<<"\"的员工.\n"; return;}}void show_dep(){if (emps.size()==0){cout<<"员工记录为空.\n";return;}double isfind=0.00;double total_salary=0.00;string dep;cout<<"请输入要查询的部门名称:";cin>>dep;cout<<"部门["<<dep<<"]的员工信息:\n";cout<<"--------------------\n\n";list<employee>::iterator iter;for(iter=emps.begin();iter!=emps.end();iter++) {if (iter->m_dep==dep){isfind++;total_salary+=iter->m_salary;print(*iter);cout<<endl;continue;}}cout<<"--------------------\n";if (isfind==0){cout<<"没有找到名称为["<<dep<<"]的部门.\n"; }else{cout<<"部门["<<dep<<"]工资统计:\n";cout<<"工资总额:"<<total_salary<<endl;cout<<"平均工资:"<<total_salary/isfind<<endl; }}。
C工资管理系统源代码

head=revise(); //修改模块
break;
case 4:
head=del(); //删除模块
break;
case 5:
search(); //查找模块
break;
case 6:
output(); //输出模块
break;
case 7:
save(head); //保存模块
break;
do
{
if(p1->actual_pay>min&&p1->actual_pay<max)
{
printf(DATA);
p1=p1->next;
flag=1;
}
else
p1=p1->next;
}while(p1!=NULL);
if(flag==0)
printf("没有该工资段的职工\n");
break;
p1->actual_pay=p1->should_pay-p1->rebate;
while(p1!=NULL)
{
if(n==1)
head=p1;
else
p2->next=p1;
n++;
p2=p1;
p1=(PAY*)malloc(sizeof(PAY));
if(p1==NULL)
{
printf("内存不足,无法创建链表!");
scanf("%d",&p1->month);
printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");
c语言编写的工资管理系统

/*程序名称:工资管理系统 *//*程序说明:该系统在磁盘上储存了某单位上月全体员工的工资信息,对于每一位职工存储以下信息:月份,职工编号,基本工资,津贴,岗贴,补贴,房贴,交通补贴,应发数,房租,储蓄,会费,个人所得税,应扣数,实发数。
个人所得税计算方法设定为:工资少于800元为0,800-1000元的部分为5%,1000-5000元的部分为10%,5000元以上的部分为20%。
该系统功能如下:1)创建存储职工工资信息的存储系统。
2)添加职工的工资信息(增加新职工时用)3)删除某职工的工资信息(职工离职或者死亡时用)4)修改某职工的部分工资信息(当月开始增加或减少某些项工资或扣款数变化)5)输出指定编号职工的工资信息(查询用)6)输出当月全体职工的工资信息(发工资用) *//*编写心得:2006年9月26日19:30-23:00共计3小时30分钟。
由于时间仓促,没有对代码进行优化设计。
对于主要的结构体也是粗粗设计了一下。
在存储上只采用了结构体数组,没用运用到二叉树等复杂的数据结构,有点遗憾。
主程序采用模块化设计,用独立的函数把功能分解开来,便于调试和扩展。
假如用C++就可以多做几个构造函数,可能会更方便点。
不过最近在学JAVA,不敢乱用C++了,怕到时候知识搞混了。
感觉稍微麻烦一点的地方是文件的输入输出部分,因为一般的书上这一章都比较靠后,老师上课也就简单的带过的,格式有点忘记了。
个人感觉现在靠C语言来做数据库不是很合适,50个元素的数组应该够了吧。
反正只要弄清那些常用函数,还有怎么一个I/O方式就可以了。
让偶想起了教偶C语言的班主任老童,想起了偶美好的青春,以及那些为了听课和MM们一大早抢前排坐位的幸福日子...总得来说还是比较轻松的,就是项目字段太多,写写麻烦(谁叫偶打字不快啊^_^)BY 雨田心梦*//* 为了调用FILE等函数 */#include "stdio.h"#include "conio.h"/* 为了调用atof()等函数 */#include "stdlib.h"#define TRUE 1/* 结构体声明 */struct zhigong{int month;float id;float jbgz;float jt;float gt;float bt;float ft;float jtbt;float yfs;float fz;float cx;float hf;float grsds;float yks;float sfs;};/* 建立50个元素的结构体数组 */ struct zhigong zg[50];/* 建立结构体变量 */struct zhigong zgone;/* 职员列表中的数量 */int n=0;/* 获得字符串 */char numstr[50];main(){char ch;n=0;/*rfile(); 使用后启动程序时系统会自动加载纪录*/while(TRUE){printf("\n");printf("===========================================\n");printf("Welcome!Please choice(1-6) : +\n");printf("1.Add oneinfomation +\n");printf("2.Delete oneinfomation +\n");printf("3.Modify oneinfomation +\n");printf("4.Print out byid +\n");printf("5.Print outall +\n");printf("6.Savedate +\n");printf("7.Loaddate +\n");printf("8.Exit+\n");printf("===========================================\n");ch=getche();switch(ch){case '1':addone();break;case '2':delone();break;case '3':modone();break;case '4':idone();break;case '5':listall();break;case '6':wfile();break;case '7':rfile();break;case '8':return;default:printf("Sorry,please choice again!\n");}}}/*计算个人所得税*/float tgrsds(float m){float sui1,sui2,sui3;float tmp;sui1=0;sui2=0;sui3=0;if(m>=5000){sui1=(m-5000)*0.2;sui2=(5000-1000)*0.1;sui3=(1000-800)*0.05;}else if(m>=1000 && m<5000){sui2=(m-1000)*0.1;sui3=(1000-800)*0.05;}else if(m>=800 && m<1000){sui3=(m-800)*0.05;}tmp=sui1+sui2+sui3;return(tmp);}/* 添加职工的工资信息 */ addone(void){printf("\n");printf("Record NO. %d \n",n+1);printf("Please put in month: \n");gets(numstr);zg[n].month=atoi(numstr);printf("Please put in zhigongbianhao: \n"); gets(numstr);zg[n].id=atof(numstr);printf("Please put in jibengongzi: \n"); gets(numstr);zg[n].jbgz=atof(numstr);printf("Please put in jintie: \n");gets(numstr);zg[n].jt=atof(numstr);printf("Please put in gangtie: \n");gets(numstr);zg[n].gt=atof(numstr);printf("Please put in butie: \n");gets(numstr);zg[n].bt=atof(numstr);printf("Please put in fangtie: \n");gets(numstr);zg[n].ft=atof(numstr);printf("Please put in jiaotongbutie: \n");gets(numstr);zg[n].jtbt=atof(numstr);zg[n].yfs=(zg[n].jbgz)+(zg[n].jt)+(zg[n].gt)+(zg[n].bt)+(zg[n].ft)+(zg[n].jtbt) ;printf("Please put in fangzu: \n");gets(numstr);zg[n].fz=atof(numstr);printf("Please put in chuxu: \n");gets(numstr);zg[n].cx=atof(numstr);printf("Please put in huifei: \n");gets(numstr);zg[n].hf=atof(numstr);zg[n].grsds=tgrsds(zg[n].yfs);zg[n].yks=(zg[n].fz)+(zg[n].cx)+(zg[n].hf)+(zg[n].grsds); zg[n].sfs=(zg[n].yfs)-(zg[n].yks);n++;}/*删除个人纪录*/delone(void){struct zhigong tmp[50];float zhigongid;int j,k;int flagfind;flagfind=0;k=0;printf("\n Please put in zhigongbianhao: \n");gets(numstr);zhigongid=atof(numstr);for(j=0;j<=n;j++){if(zg[j].id==zhigongid){flagfind=1;}else{tmp[k]=zg[j];k++;}}if(flagfind==1){for(j=0;j<=(n-1);j++){zg[j]=tmp[j];}printf("\n Record deleted! \n");n=n-1;}else{printf("\n Record not found! \n");}return;}/*修改个人纪录*/modone(void){float zhigongid;int j;int flagfind;flagfind=0;printf("\n Please put in zhigongbianhao: \n"); gets(numstr);zhigongid=atof(numstr);for(j=0;j<=n;j++){if(zg[j].id==zhigongid){printf("NO.:%d\n",j);printf("month:%d\n",zg[j].month);printf("zhigongbianhao%10.0f\n",zg[j].id);printf("jibengongzi:%10.2f\n",zg[j].jbgz);printf("Please put in jibengongzi: \n");gets(numstr);zg[j].jbgz=atof(numstr);printf("jintie:%10.2f\n",zg[j].jt);printf("Please put in jintie: \n");gets(numstr);zg[j].jt=atof(numstr);printf("gangtie:%10.2f\n",zg[j].gt);printf("Please put in gangtie: \n");gets(numstr);zg[j].gt=atof(numstr);printf("butie:%10.2f\n",zg[j].bt);printf("Please put in butie: \n");gets(numstr);zg[j].bt=atof(numstr);printf("fangtie:%10.2f\n",zg[j].ft);printf("Please put in fangtie: \n");gets(numstr);zg[j].ft=atof(numstr);printf("jiaotongbutie:%10.2f\n",zg[j].jtbt);printf("Please put in jiaotongbutie: \n");gets(numstr);zg[j].jtbt=atof(numstr);zg[j].yfs=(zg[j].jbgz)+(zg[j].jt)+(zg[j].gt)+(zg[j].bt)+(zg[j].ft) +(zg[j].jtbt);printf("fangzu:%10.2f\n",zg[j].fz);printf("Please put in fangzu: \n");gets(numstr);zg[j].fz=atof(numstr);printf("chuxu:%10.2f\n",zg[j].cx);printf("Please put in chuxu: \n");gets(numstr);zg[j].cx=atof(numstr);printf("huifei:%10.2f\n",zg[j].hf);printf("Please put in huifei: \n");gets(numstr);zg[j].hf=atof(numstr);zg[j].grsds=tgrsds(zg[j].yfs);zg[j].yks=(zg[j].fz)+(zg[j].cx)+(zg[j].hf)+(zg[j].grsds);zg[j].sfs=(zg[j].yfs)-(zg[j].yks);flagfind=1;}else{flagfind=0;}}if(flagfind==0)printf("\n Can not find record! \n");return;}/*随机从内存中查找纪录根据id*/idone(void){float zhigongid;int j;int flagfind;flagfind=0;printf("\n Please put in zhigongbianhao: \n");gets(numstr);zhigongid=atof(numstr);for(j=0;j<=n;j++){if(zg[j].id==zhigongid){printf("\n %d record found! \n |",j+1);printf("month:%d |",zg[j].month);printf("zhigongbianhao%10.0f |",zg[j].id);printf("jibengongzi:%10.2f |",zg[j].jbgz);printf("jintie:%10.2f |",zg[j].jt);printf("gangtie:%10.2f |",zg[j].gt);printf("butie:%10.2f |",zg[j].bt);printf("fangtie:%10.2f |",zg[j].ft);printf("jiaotongbutie:%10.2f |",zg[j].jtbt);printf("yingfashu:%10.2f |",zg[j].yfs);printf("fangzu:%10.2f |",zg[j].fz);printf("chuxu:%10.2f |",zg[j].cx);printf("huifei:%10.2f |",zg[j].hf);printf("gerensuodeshui:%10.2f |",zg[j].grsds);printf("yingkoushu:%10.2f |",zg[j].yks);printf("shifashu:%10.2f\n",zg[j].sfs);flagfind=1;}else{flagfind=0;}}if(flagfind==0)printf("\n Can not find record! \n");return;}/* 输出当月全体职工的工资信息 */listall(void){int j;if(n<1){printf("\n No record! \n");}else{for(j=0;j<n;j++){printf("\n NO:%d |",j+1);printf("month:%d |",zg[j].month);printf("zhigongbianhao%10.0f |",zg[j].id);printf("jibengongzi:%10.2f |",zg[j].jbgz);printf("jintie:%10.2f |",zg[j].jt);printf("gangtie:%10.2f |",zg[j].gt);printf("butie:%10.2f |",zg[j].bt);printf("fangtie:%10.2f |",zg[j].ft);printf("jiaotongbutie:%10.2f |",zg[j].jtbt);printf("yingfashu:%10.2f |",zg[j].yfs);printf("fangzu:%10.2f |",zg[j].fz);printf("chuxu:%10.2f |",zg[j].cx);printf("huifei:%10.2f |",zg[j].hf);printf("gerensuodeshui:%10.2f |",zg[j].grsds);printf("yingkoushu:%10.2f |",zg[j].yks);printf("shifashu:%10.2f\n",zg[j].sfs);}}}/* 把所有纪录从内存中写到磁盘gongzi.rec中 */wfile(void){FILE *fptr;printf("\n Saving date... \n");if(n<1){printf("\n No record! \n");return;}if((fptr=fopen("gongzi.rec","wb"))==NULL)printf("Can not open file gongzi.rec! \n"); else{fwrite(zg,sizeof(zg[0]),n,fptr);fclose(fptr);printf("File of %d records written! \n",n ); }}/* 把所有纪录从磁盘gongzi.rec读到数组gz中 */rfile(void){FILE *fptr;n=0;printf("\n Loading date... \n");if((fptr=fopen("gongzi.rec","rb"))==NULL) printf("Can not open file gongzi.rec! \n"); else{while(fread(&zg[n],sizeof(zg[n]),1,fptr)==1) n++;fclose(fptr);printf(" Total %d records read! \n",n);}}。
C工资管理系统源代码

/*插入模块*/
PAY *insert()
{
PAY *p3=NULL;
char sel;
head=open();
if(head==NULL)
return NULL;
else
do
{
printf("请输入要插入的职工信息:\n");
p3=(PAY*)malloc(sizeof(PAY));
if(p3==NULL)
C工资管理系统源代码
#include <>
#include <>
#include <>
#include <>
#include <>
#define TITLE "\n月份工号姓名应发工资各种折扣实发工资\n"
#define DATA " %2d %4ld %-10s % % %\n",p1->month,p1->num,p1->name,p1->should_pay,p1->rebate,p1->actual_pay
scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);
printf("房租扣款,公积金,水电费,其它扣款:\n");
scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);
C工资管理系统源代码精编

C工资管理系统源代码精编Document number:WTT-LKK-GBB-08921-EIGG-22986#include <>#include <>#include <>#include <>#include <>#define TITLE "\n 月份工号姓名应发工资各种折扣实发工资\n"#define DATA " %2d %4ld %-10s % % %\n",p1->month,p1->num,p1->name,p1->should_pay,p1->rebate,p1->actual_paytypedef struct pay{long num;short month;char name[20];float gw,jn,zw,zl,jt,yj;float should_pay;float fz,gj,sd,others;float rebate;float actual_pay;struct pay *next;}PAY;FILE *fp;PAY *p1=NULL,*p2=NULL,*head=NULL;void menu();PAY *input();void output();void save(PAY *head);PAY *open();PAY *insert();void search();PAY *del();PAY *revise();/*主程序模块*/void main(void){short sel;do{menu();scanf("%d",&sel);switch(sel){case 1:head=input(); 建工资档案\n");printf("\t\t\t\t2.新增工资信息\n"); printf("\t\t\t\t3.修改工资信息\n"); printf("\t\t\t\t4.删除工资信息\n"); printf("\t\t\t\t5.查找工资信息\n"); printf("\t\t\t\t6.分类信息列表\n"); printf("\t\t\t\t7.保存信息\n"); printf("\t\t\t\t0.退出\n"); printf("\n\n\n\n\n\n\n\n");}/*输入模块*/PAY *input(){short n=1;p1=(PAY*)malloc(sizeof(PAY));if(p1==NULL){printf("内存不足,无法创建链表!"); getch();}printf("\n请输入第%d位职工的信息(以工号为0结束):\n",n);printf(" 工号:");scanf("%d",&p1->num);if(p1->num==0){printf("按任意键返回!");getch();free(p1);return 0;}getchar();printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;while(p1!=NULL){if(n==1)head=p1;elsep2->next=p1;n++;p2=p1;p1=(PAY*)malloc(sizeof(PAY));if(p1==NULL){printf("内存不足,无法创建链表!");getch();}printf("请输入第%d位职工的信息(以工号为0结束):\n",n);printf(" 工号:");scanf("%d",&p1->num);getchar();if(p1->num==0){p1=NULL;break;}printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;}p2->next=NULL;部清单\n");printf("\t\t2.按月输出\n");printf("\t\t3.按工资段输出\n");printf("\t\t0.返回\n");scanf("%d",&sel);}while(sel!=1&&sel!=2&&sel!=3&&sel!=0);head=open();if(head==NULL)return;elseswitch(sel){case 1:printf("\n\t\t\t ******全部清单******\n"); printf(TITLE);p1=head;do{printf(DATA);p1=p1->next;}while(p1!=NULL);break;case 2:flag=0;printf("输入要查的月份:");scanf("%d",&month);printf("\n\t\t\t******第%d月工资清单******\n",month);printf(TITLE);p1=head;do{if(p1->month==month){printf(DATA);p1=p1->next;flag=1;}elsep1=p1->next;}while(p1!=NULL);if(flag==0)printf("没有该月清单\n");break;case 3:flag=0;printf("输入最低工资:");scanf("%f",&min);printf("输入最高工资:");scanf("%f",&max);printf("\n\t\t ******%到%工资的名单******\n",min,max);printf(TITLE);p1=head;do{if(p1->actual_pay>min&&p1->actual_pay<max) {printf(DATA);p1=p1->next;flag=1;}elsep1=p1->next;}while(p1!=NULL);if(flag==0)printf("没有该工资段的职工\n"); break;case 0:break;}}while(sel!=0);}/*保存文件*/void save(PAY *head){short write;fp=fopen("","w");if(fp==NULL){printf("创建文件失败!");getch();return;}p1=p2=head;while(p1!=NULL){write=fwrite(p1,sizeof(PAY),1,fp); if(!write){printf("无法写入文件!");getch();return;}p1=p1->next;}fclose(fp);printf("成功存盘!");getch();}/*打开文件*/PAY *open(){short n=1,read;fp=fopen("","r");if(fp==NULL){printf("无法打开档案文件!");getch();return NULL;}if((p1=p2=(PAY*)malloc(sizeof(PAY)))==NULL) {printf("内存不足!");getch();return NULL;}read=fread(p1,sizeof(PAY),1,fp);if(!read){printf("文件读取出错!1");getch();return NULL;}if(p1->next==NULL)head=p1;else{do{if(n==1)head=p1;elsep2->next=p1;n++;p2=p1;if((p1=(PAY*)malloc(sizeof(PAY)))==NULL) {printf("内存不足!");getch();return NULL;}read=fread(p1,sizeof(PAY),1,fp);if(!read){printf("文件读取出错!2");getch();return NULL;}}while(p1->next!=NULL);p2->next=p1;}return head;fclose(fp);}/*插入模块*/PAY *insert(){PAY *p3=NULL;char sel;head=open();if(head==NULL)return NULL;elsedo{printf("请输入要插入的职工信息:\n"); p3=(PAY*)malloc(sizeof(PAY));if(p3==NULL){printf("内存不足,无法创建链表!"); getch();printf(" 工号:");scanf("%d",&p3->num);getchar();printf(" 姓名:");gets(p3->name);printf(" 工资月份:");scanf("%d",&p3->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p3->gw,&p3->jn,&p3->zw,&p3->zl,&p3->jt,&p3->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p3->fz,&p3->gj,&p3->sd,&p3->others);p3->should_pay=p3->gw+p3->jn+p3->zw+p3->zl+p3->jt+p3->yj;p3->rebate=p3->fz+p3->gj+p3->sd+p3->others;p3->actual_pay=p3->should_pay-p3->rebate;p1=head;while(p1!=NULL)p2=p1;p1=p1->next;}p2->next=p3;p3->next=NULL;printf("成功插入,是否继续是(Y)否(N)\n"); sel=getch();}while(sel=='Y'||sel=='y');printf("\n任意键返回,并存盘……\n");getch();return head;}/*查找模块*/void search(){short sel;long num;char name[20],choose;head=open();if(head==NULL)return;do{do{printf("\n选择查找方式:\n"); printf("\t\t1.按工号查找\n"); printf("\t\t2.按姓名查找\n"); scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要查的工号:");scanf("%ld",&num);break;case 2:printf("输入要查的姓名:");gets(name);break;}p1=head;while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) 工号删除\n");printf("\t\t2.按姓名删除\n");scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要删除的工号:");scanf("%ld",&num);break;case 2:printf("输入要删除的姓名:");gets(name);break;}p1=head;if((p1->num==num)||strcmp(p1->name,name)==0) {head=p1->next;printf("删除信息成功!");}else{while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)){p2=p1;p1=p1->next;}if((p1->num==num)||strcmp(p1->name,name)==0) {p2->next=p1->next;free(p1);printf("\n删除信息成功!\n");}elseprintf("\n没有该信息!\n");}printf("是否继续是(Y)否(N)\n");choose=getch();}while(choose=='Y'||choose=='y');printf("任意键返回,并存盘……");getch();return head;}/*修改模块*/PAY *revise(){short sel;long num;char name[20],choose;head=open();if(head==NULL)return NULL;elsedo{do{printf("\n查找要修改的对象:\n"); printf("\t\t1.按工号查找\n");printf("\t\t2.按姓名查找\n");scanf("%d",&sel);getchar();}while(sel!=1&&sel!=2);switch(sel){case 1:printf("输入要查的工号:");scanf("%ld",&num);break;case 2:printf("输入要查的姓名:");gets(name);break;}p1=head;while((p1->next!=NULL)&&(p1->num!=num)&&(strcmp(p1->name,name)!=0)) //用成p1!=NULL有问题p1=p1->next;if((p1->num==num)||strcmp(p1->name,name)==0) {printf("您要修改的原始信息如下:\n");printf(TITLE);printf(DATA);printf("\n将上述信息改为如下信息:\n");printf(" 工号:");scanf("%d",&p1->num);getchar();printf(" 姓名:");gets(p1->name);printf(" 工资月份:");scanf("%d",&p1->month);printf(" 岗位工资,技能工资,职务津贴,职龄津贴,交通补贴,业绩津贴:\n");scanf("%f,%f,%f,%f,%f,%f",&p1->gw,&p1->jn,&p1->zw,&p1->zl,&p1->jt,&p1->yj);printf(" 房租扣款,公积金,水电费,其它扣款:\n");scanf("%f,%f,%f,%f",&p1->fz,&p1->gj,&p1->sd,&p1->others);p1->should_pay=p1->gw+p1->jn+p1->zw+p1->zl+p1->jt+p1->yj;p1->rebate=p1->fz+p1->gj+p1->sd+p1->others;p1->actual_pay=p1->should_pay-p1->rebate;}elseprintf("你要修改的信息不存在!\n"); printf("是否继续是(Y)否(N)\n"); choose=getch();}while(choose=='Y'||choose=='y');printf("任意键返回,并存盘……");getch();return head;}。
c语言职工工资管理系统代码

c语言职工工资管理系统代码随着社会的发展和经济的进步,职工工资管理成为了企业管理中的重要一环。
为了提高工资管理的效率和准确性,许多企业开始采用计算机软件来进行工资管理。
本文将介绍一个基于C语言的职工工资管理系统代码。
首先,我们需要定义一些基本的数据结构和变量。
在这个系统中,我们需要记录每个职工的姓名、工号、基本工资、津贴、扣款等信息。
我们可以使用结构体来定义这些信息,例如:```cstruct Employee {char name[20];int id;float basicSalary;float allowance;float deduction;};```接下来,我们可以定义一些函数来实现不同的功能。
例如,我们可以编写一个函数来添加新的职工信息:```cvoid addEmployee(struct Employee *employees, int *count) { printf("请输入职工姓名:");scanf("%s", employees[*count].name);printf("请输入职工工号:");scanf("%d", &employees[*count].id);printf("请输入职工基本工资:");scanf("%f", &employees[*count].basicSalary);printf("请输入职工津贴:");scanf("%f", &employees[*count].allowance);printf("请输入职工扣款:");scanf("%f", &employees[*count].deduction);(*count)++;}```我们还可以编写一个函数来计算每个职工的实际工资:```cfloat calculateSalary(struct Employee employee) {return employee.basicSalary + employee.allowance - employee.deduction;}```接下来,我们可以编写一个函数来显示所有职工的信息和实际工资:```cvoid displayEmployees(struct Employee *employees, int count) {printf("姓名\t工号\t基本工资\t津贴\t扣款\t实际工资\n");for (int i = 0; i < count; i++) {printf("%s\t%d\t%.2f\t\t%.2f\t%.2f\t%.2f\n", employees[i].name, employees[i].id, employees[i].basicSalary, employees[i].allowance, employees[i].deduction, calculateSalary(employees[i]));}}```最后,我们可以编写一个主函数来实现整个系统的流程:```cint main() {struct Employee employees[100];int count = 0;int choice;do {printf("请选择操作:\n");printf("1. 添加职工信息\n");printf("2. 显示职工信息\n");printf("3. 退出\n");scanf("%d", &choice);switch (choice) {case 1:addEmployee(employees, &count);break;case 2:displayEmployees(employees, count);break;case 3:printf("感谢使用职工工资管理系统!\n"); break;default:printf("无效的选择,请重新输入!\n");break;}} while (choice != 3);return 0;}```通过以上代码,我们可以实现一个简单的职工工资管理系统。
员工工资管理系统(c语言编程)

#include<stdio.h〉#include〈string。
h〉#include<ctype.h>#include〈malloc。
h>#define null 0typedef struct Info1{char num[10];char name[10];char depar[10];char yfsalary[10];char aband[10];char tax[10];char sfsalary[10];struct Info1 *next;}Info2;typedef struct Info1 *Info;Info head;void display();void find();void modify();void add();void del();void list();void listOne(Info s);Info isExists(char *num);void init();void init(){head=(Info)malloc(sizeof(Info2));head-〉next=null;}void main(){init();while(1){char c;display();scanf("%c”,&c);switch(c){case '1’:find();break;case '2':add();break;case '3':modify();break;case '4':del();break;case '5’:list();break;case '6’:printf(”\t\t..。
退出系统!\n");return;default:printf(”\t\t输入错误!请按任意键返回重新选择(1-7)\n”);getchar ();}}}void display(){printf("\n\t** 欢迎使用员工信息管理系统**\n\n”);printf(”\t请选(1-7):\n");printf(”\t============================================\n”);printf("\t\t1。
c++实习小型公司工资管理系统的设计源程序

cout<<"------------------------------------------"<<endl;
djxt();
cin>>j;breakt<<"请等待…"<<endl;
{switch(j)
{case 1:
{for(i=0;i<4;i++)
t[i].display1();
cout<<"-------------"<<endl;
for(i=0;i<4;i++)
m[i].display2();
cout<<"-------------"<<endl;
for(i=0;i<8;i++)
{
cout<<"★★小型公司工资管理系统★★"<<endl;
cout<<"┌─────────────┐"<<endl;
cout<<"│ 请选择您所需的操作 │"<<endl;
cout<<"│ 数据输入:1,并按回车键 │ "<<endl;
cout<<"│ 数据统计:2,并按回车键 │"<<endl;
cout<<"职工基本情况一览表如下"<<endl;
c语言职工工资管理系统代码

C语言职工工资管理系统代码1. 项目简介本项目是一个用C语言编写的职工工资管理系统。
该系统旨在帮助企业或组织更好地管理职工的工资信息,包括薪资计算、数据存储和查询等功能。
通过该系统,可以提高工资管理的效率和准确性,减少人力资源部门的负担。
2. 功能需求本系统需要实现以下功能:•添加新员工:输入员工姓名、基本工资、津贴等信息,并生成唯一的员工ID。
•删除员工:根据员工ID删除指定员工信息。
•修改员工信息:根据员工ID修改指定员工的基本信息。
•计算薪资:根据员工ID计算指定员工的实际薪资,并将结果保存到数据库中。
•查询薪资:根据员工ID查询指定员工的薪资信息。
3. 数据结构设计为了存储职工的基本信息和薪资数据,我们可以使用以下数据结构:3.1 员工结构体定义struct Employee {int id; // 员工IDchar name[50]; // 员工姓名float basicSalary; // 基本工资float allowance; // 津贴float actualSalary; // 实际薪资};3.2 员工数组定义struct Employee employees[100]; // 最多存储100个员工的信息int employeeCount = 0; // 当前员工数量4. 系统实现4.1 添加新员工void addEmployee() {struct Employee employee;printf("请输入员工姓名:");scanf("%s", );printf("请输入基本工资:");scanf("%f", &employee.basicSalary);printf("请输入津贴:");scanf("%f", &employee.allowance);employee.id = employeeCount + 1;employee.actualSalary = employee.basicSalary + employee.allowance;employees[employeeCount] = employee;employeeCount++;printf("添加成功!员工ID为:%d\n", employee.id);}4.2 删除员工void deleteEmployee() {int id;printf("请输入要删除的员工ID:");scanf("%d", &id);int index = findEmployeeIndex(id);if (index == -1) {printf("未找到对应的员工信息。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include<iomanip.h>#include<iostream.h>#include<fstream.h>#include<stdlib.h> class Employ// 基类- 雇员类{ protected:int num;char name[10];char sex;int age;int wage;public:virtual void set()=0;virtual void print()=0;virtual void reserved()=0;};class Manager:public Employ// 经理类{public:void set();void print();void reserved();};class Salesman:public Employ// 销售员类{protected:int salesvolume;int snum;public:void set();void print();void reserved();void printinfor();int getsales(){return salesvolume;}int getsnum(){return snum;}};class MarketMan:public Manager// 销售经理类{ protected: int salesvolume; public:void set();void print();void reserved();int resetwage();int getnum(){return num;} char*getname() {return name;} int getamount(Salesman s[],int n){ salesvolume=0; for(int i=0;i<n;i++) {if(s[i].getsnum()==num) salesvolume+=s[i].getsales();} return salesvolume;}};class Technician:public Employ// 技术员类{ protected: int worktime; public:void set();void print();void reserved();};void Manager::set(){ wage=8000;cout<<" 经理的编号:"; cin>>num;cout<<" 其姓名:"; cin>>name;cout<<" 性别(m/w):"; cin>>sex;cout<<" 年龄:";cin>>age;}void Manager::print()// 经理类成员函数{cout<<" | ------------------ 1 ---------------- 1---------------- 1 ---- "<<endl;cout<<" I "<<setw(12)<<num<<" | "<<setw(12)<<name<<" cout<<" | "<<setw(12)<<age<<" I "<<setw(12)<<wage<<" I }void Manager::reserved(){ofstream employf("E:\\05-29\\gzglxt.txt",ios::app);employf<<" 经理的编号:"<<num<<endl<<"其姓名:"<<name<<endl<<" 性别(m/w):"<<sex<<endl<<" 年龄:"<<age<<endl;}void MarketMan::set(){wage=resetwage();cout<<" 销售经理的编号:";cin>>num;cout<<" 其姓名:";cin>>name;cout<<" 性别(m/w):";cin>>sex;cout<<" 年龄:";cin>>age;}void MarketMan::print(){resetwage();cout<<" | ------------------ 1 ---------------- 1---------------- 1 ----"<<endl;cout<<" I "<<setw(12)<<num<<" I "<<setw(12)<<name<<" cout<<" I "<<setw(12)<<age<<" I "<<setw(12)<<wage<<" I }void MarketMan::reserved(){ofstream employf("E:\\05-29\\gzglxt.txt",ios::app);employf<<" 销售经理的编号:"<<num<<endl<<"其姓名:"<<name<<endl"<<setw(12)<<sex; "<<endl;"<<setw(12)<<sex; "<<endl;<<" 年龄:"<<age<<endl; }int MarketMan::resetwage(){wage=5000+int(salesvolume*0.005); return wage;}void Salesma n::set()〃销售员类定义{cout<<" 销售员的编号:";cin>>num;cout<<" 其姓名:";cin>>name;cout<<" 性别(m/w):";cin>>sex;cout<<" 年龄:";cin>>age;cout<<" 销售额:";cin>>salesvolume;cout<<" 所属销售经理的编号:"; cin>>snum;wage=int(salesvolume*0.04);}void Salesman::printinfor(){cout<<" | --------------------- 1------------------- 1 ----------------- cout<<" | "<<setw(14)<<num<<" | "<<setw(14)<<name<<" "<<endl;}void Salesman::print(){cout<<" | ------------- 1-------------- 1-------------- 1------------------------ H------ 1 "<<endl;cout<<" | "<<setw(8)<<num<<" | "<<setw(10)<<name<<" | cout<<" | "<<setw(10)<<age<<" | "<<setw(10)<<wage<<" "<<endl;}void Salesman::reserved(){ofstream employf("E:\\05-29\\gzglxt.txt",ios::app);employf<<" 销售员的编号:"<<num<<endl<<"其姓名:"<<name<<endl"<<endl;"<<setw(14)<<salesvolume<<" |"<<setw(10)<<sex;| "<<setw(16)<<getsnum()<<"<<" 年龄:"<<age<<endl<<" 销售额:"<<salesvolume<<endl<<" 所属销售经理的编号"<<snum<<endl;}void Technician::set()// 技术员类定义{cout<<" 技术员的编号:";cin>>num;cout<<" 其姓名:";cin>>name;cout<<" 性别(m/w):";cin>>sex;cout<<" 年龄:";cin>>age;cout<<" 工作时间:";cin>>worktime; wage=worktime*100;}void Technician::print(){cout<<" | --------------------- 1------------------ 1 ------------------ 1 ----- "<<endl;cout<<" | "<<setw(12)<<num<<" | "<<setw(12)<<name<<" cout<<" | "<<setw(12)<<age<<" | "<<setw(12)<<wage<<" | } void Technician::reserved(){ofstream employf("E:\\05-29\\gzglxt.txt",ios::app); employf<<" 技术员的编号:"<<num<<endl <<"其姓名:"<<name<<endl<<" 性别(m/w):"<<sex<<endl<<" 年龄:"<<age<<endl<<"工作时间:"<<worktime<<endl;}//主函数int t,m,s,mm;Technician*pt;Manager*pm;Salesman*ps;MarketMan*pmm;void setin();"<<setw(12)<<sex; "<<endl;void count();void printdata(); void reservedall(); void single();void main(){cout<<" 请分别输入技术员,经理,销售员,销售经理人数cin>>t>>m>>s>>mm;pt=new Technician[t]; pm=new Manager[m]; ps=new Salesman[s]; pmm=new MarketMan[mm];if((!pt)||(!pm)||(!ps)||(!pmm)){cout<<" 堆内存分配失败!"<<endl;exit(1);} single();}void single(){cout<<" ★★小型公司工资管理系统★★"<<endl; COUt<<" I ---------------------------------cout<<" | 请选择所需的操作cout<<" |cout<<" |数据输入:1,并按回车键cout<<" |cout<<" | 数据统计:2,并按回车键cout<<" |cout<<" | 数据打印:3,并按回车键 |"<<endl; cout<<" | | "<<endl; cout<<" | 数据备份:4,并按回车键 | "<<endl;cout<<" | | "<<endl; cout<<" | 退出系统:5,并按回车键 | "<<endl;cout<<" | | "<<endl; cout<<" 1 ---------------------------------------- 1"<<e ndl;int choice;cin>>choice;:"<<endl;"<<endl;| "<<endl;| "<<endl;"<<endl;| "<<endl;"<<endl;| "<<endl;cout<<" 请选择一个操作:"<<endl;switch(choice){case 1:setin();case 2:count();case 3:printdata();case 4:reservedall();case 5:exit(0);}}void setin(){Menu1:cout<<" ★★小型公司工资管理系统★★"<<endl;cout<<" | --------------------------------------------- 1"<<endl; cout<<" | 请选择所需的操作丨"<<endl; cout<<" | | "<<endl; cout<<" |技术员数据输入: 1, 并按回车键| "<<endl; cout<<" ||"<<endl;cout<<" |经理数据输入: 2, 并按回车键| "<<endl; cout<<" ||"<<endl;cout<<" |销售员数据输入: 3, 并按回车键| "<<endl; cout<<" ||"<<endl;cout<<" |销售经理数据输入: 4, 并按回车键| "<<endl; cout<<" ||"<<endl;cout<<" |返回上一级菜单: 5, 并按回车键| "<<endl; cout<<" 11"<<endl; cout<<" 请选择一个操作";int ch1,i; cin>>ch1; switch(ch1) { case 1:{for(i=0;i<t;i++) pt[i].set();cout<<" -------------------------------- "<<endl;goto Menu1;} case 2:{for(i=0;i<m;i++)pm[i].set();cout<<" --------------------------------"<<endl;goto Menu1;}case 3:{for(i=0;i<s;i++) ps[i].set(); cout<<" - "<<endl;goto Menu1;}case 4:{for(i=0;i<mm;i++) pmm[i].set(); cout<<" "<<endl;goto Menu1;} case5:single();}}void count() { Menu2:cout<<" ★★小型公司工资管理系统★★"<<endl;cout<<" 1 ---------------------------------------------- -------------------- 1"<<endl;cout<<" | 请选择所需的操作| "<<endl;cout<<" || "<<endl;cout<<" |各销售经理下属销售员业绩统计: 1,并按回车键 | "<<endl;cout<<" || "<<endl;cout<<" |销售经理按工资排序: 2,并按回车键 | "<<endl;cout<<" || "<<endl;cout<<" |返回上一级菜单: 3,并按回车键 | "<<endl;cout<<" 1 ---------------------------------------------- -------------------- 1"<<endl;cout<<" 请选择一个操作";int ch2,i,j;cin>>ch2;switch(ch2){case 1:{for(i=0;i<mm;i++){cout<<" 职工号为:"<<pmm[i].getnum()<<" 销售经理:"<<pmm[i].getname()<<" 下属销售员的业绩为:"<<endl;cout<<" | -------------------- 1 ------------------- 1------------------- 1"<<endl;cout<<" |职工号|姓名|销售额| "<<endl;for(j=0;j<s;j++)if(pmm[i].getnum()= =ps[j].getsnum())ps[j].printinfor();cout<<" | -------- 11 -------------------- 1"<<endl;cout<<" | 销售额总计:| "<<setw(22)<<pmm[i].getamount(ps,s)<<" |"<<endl;}cout<<""<<endl;goto Menu2;}case 2:{cout<<" 销售经理按工资排序为:"<<endl;MarketMan pmmm; for(i=1;i<mm;i++) for(j=0;j<mm-i;j++)if(pmm[j].getamount(ps,s)<pmm[j+1].getamount(ps,s)){pmmm=pmm[j]; pmm[j]=pmm[j+1]; pmm[j+1]=pmmm;}cout<<" I ------------------ 1---------------- 1 ---------------- 1 ----------------- r-------- 1"<<endl;cout<<" | 职工号丨姓名丨性别丨年龄工资I "<<endl;for(i=0;i<mm;i++) pmm[i].print();cout<<" 1-------------------- 1------------------- 1------------------- 1------------------- L---------- 1 "<<e ndl;cout<<" ------------------------------------------ "<<endl;goto Menu2;}case 3:single();}}void printdata(){Menu3:cout<<" ★★小型公司工资管理系统★★"<<endl;cout<<" i --------------------------------------------- 1"<<endl;cout<<" | 请选择所需的操作| "<<endl;cout<<" | | "<<endl;cout<<" |技术员数据输出: 1, 并按回车键| "<<endl;cout<<" ||"<<endl;cout<<" |经理数据输出: 2, 并按回车键| "<<endl;cout<<" ||"<<endl;cout<<" |销售员数据输出: 3, 并按回车键| "<<endl;cout<<" ||"<<endl;cout<<" |销售经理数据输出: 4, 并按回车键| "<<endl;cout<<" ||"<<endl;cout<<" |返回上一级: 5, 并按回车键| "<<endl;cout<<" 11"<<endl;cout<<" 请选择一个操作";int ch3,i;cin>>ch3;switch(ch3) {case 1:{cout<<" 技术员"<<endl<<endl;cout<<" I ----------------- 1 ---------------- 1 ----------------- 1---------------- 1------------- 1"<<endl;cout<<" | 职工号丨姓名丨性别丨年龄资 | "<<endl;for(i=0;i<t;i++) pt[i].print();cout<<" 1-------------------- 1------------------- 1------------------- 1------------------ 1---------------- 1 "<<e ndl;cout<<" ----------------------------------------- "<<endl;goto Menu3;}case 2:{ cout<<" 经理"<<endl<<endl;cout<<" i ------------------ 1---------------- 1 ---------------- 1---------------- 1 ------------- 1 "<<endl;cout<<" | 职工号 | 姓名| 性别| 年龄资 | "<<endl;for(i=0;i<m;i++) pm[i].print();cout<<" 1-------------------- 1------------------- 1------------------- 1------------------ 1---------------- 1 "<<e ndl;cout<<" ----------------------------------------- "<<endl;goto Menu3;}case 4:{cout<<" 销售经理"<<endl<<endl;cout<<" i ------------------ 1--------------- 1 ------------------ 1 --------------- 1 ----------——I "<<endl;cout<<" | 职工号 | 姓名| 性别| 年龄资 | "<<endl;for(i=0;i<mm;i++) pmm[i].print();cout<<" 1-------------------- 1------------------- 1------------------- 1------------------ 1---------------- 1 "<<e ndl;cout<<" ----------------------------------------- "<<endl;goto Menu3;}case 3:{cout<<" 销售员"<<endl<<endl;cout<<" i ------------- 1-------------- 1 -------------- 1------------- 1-------------- 1------- ——————————I "<<endl;cout<<" | 职工号 | 姓名 | 性别 | 年龄 | 工资部门经理编号| "<<endl;所属for(i=0;i<s;i++)ps[i].print();cout<<" 1-------------- 1 ----------- 1---------- 1 ---------- 1--------- 1"——------------------- 1"<<e ndl;cout<<" ----------------------------------------- "<<endl;goto Menu3;} case 5:single();}}void reservedall() {Menu4:cout<<" ★★小型公司工资管理系统★★"<<endl;cout<<" | --------------------------------------------- 1"<<endl;cout<<" | 请选择所需的操作丨"<<endl;cout<<" ||cout<<" |技术员数据备份: 1,并按回车键| "<<endl; cout<<" ||"<<endl; cout<<" |经理数据备份: 2,并按回车键| "<<endl;cout<<" ||"<<endl; cout<<" |销售员数据备份: 3,并按回车键| "<<endl; cout<<" ||"<<endl; cout<<" |销售经理数据备份: 4,并按回车键| "<<endl;cout<<" ||"<<endl; cout<<" |返回上一级: 5,并按回车键| "<<endl;cout<<" 1 ------------------------------------------------- 1"<<e ndl; cout<<" 请选择一个操作"int ch4,i;cin>>ch4;switch(ch4){case 1:{for(i=0;i<t;i++) pt[i].reserved();goto Menu4;}case 2:{for(i=0;i<m;i++) pm[i].reserved();goto Menu4;}case 3:{for(i=0;i<s;i++) ps[i].reserved();goto Menu4;}case 4:{for(i=0;i<mm;i++)pmm[i].reserved();goto Menu4;}case 5:single();。