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

C员工工资管理系统源代码
#include <iomanip>
#include <iostream>
#include <fstream>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
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 name[N]; //用来存放姓名
char sex[N]; //用来存放性别
long id; //用来存放编号
float paid[3]; //用来存放工资
int total; //用来存放总工资
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); //指针函数*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(); //读取文件信息
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)
{//定义一个指向struct student的结构体指针函数*creat()用来录入职工信息.
char ch[N];n=0; //用来存放职工姓名
p1=p2=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元
cout<<" -------------<<请建立员工信息表,在姓名处键以# 结束输入!>>--------------"<<endl;
cout<<" 姓名:";
cin>>ch;
head=NULL; //给指针head赋初值。

合集下载

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文献写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文献读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题, 欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&st[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3){printf("错误次数太多, 退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误, 请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.记录职工总工资\n");printf("5.保存到文献\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();elseif (x==6){printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");// printf("333333\n");return;}else{printf("输入命令错误, 返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超过职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n"); printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完毕!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic,st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文献\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序, 自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);}。

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

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

#include 〈iomanip〉#include 〈iostream〉#include <fstream>#include 〈malloc.h〉#include <stdlib。

h〉#include 〈string.h>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 name[N]; //用来存放姓名char sex[N];//用来存放性别long id; //用来存放编号float paid[3];//用来存放工资int total; //用来存放总工资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); //指针函数*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(); //读取文件信息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){//定义一个指向struct student的结构体指针函数*creat()用来录入职工信息.char ch[N];n=0;//用来存放职工姓名p1=p2=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元cout〈〈" --—----------<<请建立员工信息表,在姓名处键以#结束输入!〉>--------—-—---”〈〈endl;cout<〈" 姓名:";cin〉〉ch;head=NULL; //给指针head赋初值while (strcmp(c h,”#")!=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赋给指针headelse p2—>next=p1; //否则将p1赋给p2所指结构体的next指针p2=p1;//将指针p1赋给指针p2n++;//将职工人数n的值加1cout<〈"\n 姓名:”;cin〉>ch;//将输入的姓名存放到字符数组ch中}p2—〉next=NULL; //将p2所指结构体的next指针重新赋空值return (head);//将输入的第一组职工信息返回}//--—-———-————--->定义output()函数将职工的信息从头指针所指内容开始输出void Information::output(student *head){system("cls”);if(head==NULL)cout〈<”这是一个空表,请先输入员工信息!\n”;else{cout〈<"-—-——-—---———--—--—--—--——---—----—--------——------——-----——-—-—-—-—---——-—-——-\n";cout<〈”*职工工资信息表*\n”;cout<<"———-—-———-———-————————————---————--—----——-—--—-—-—-—-——-----——-—----------———-\n”;cout〈〈"|编号| |姓名| |性别||基本工资| |加班工资||其他奖金||总额|\n”;cout〈〈”-—-—-————————-———-——-————--—---——---—-—--——-—---——-——-—-——--—-———-—---—--—---——\n";p1=head;//将头指针赋给pdo{cout〈〈setw(6)〈<p1->id<<setw(10)〈<p1—>name〈<setw(10)〈<p1—>sex<<setw(10)〈〈p1-〉paid[0]<〈setw(10)〈<p1->paid[1]<〈setw(12)<〈p1-〉paid[2]〈<setw(12)<<p1—>total〈<endl;cout〈〈”-——--——---————---—-——-——-———-——---————-—-—----—-——---——-———-—-—-—-—----———--—--\n";p1=p1—〉next; //将下一组职工信息的next指针赋给p}while(p1!=NULL); //若指针p非空则继续,目的是把所有的职工信息都传给指针p 然后输出。

c语言职工工资管理系统代码

c语言职工工资管理系统代码

C语言职工工资管理系统代码简介职工工资管理是一项重要的任务,它涉及到工资计算、薪资发放、绩效评估等方面。

为了提高管理的有效性和准确性,许多公司和组织都开发了各种各样的工资管理系统。

本文将介绍一种基于C语言开发的职工工资管理系统代码。

代码功能及特点1. 基本功能•添加新员工信息•更新员工信息•计算员工工资•发放工资•查询员工信息•统计工资情况2. 特点•简单易懂:代码使用C语言编写,阅读和理解都相对简单。

•高效可靠:代码采用模块化设计,结构清晰,运行效率高,容错性强。

•跨平台支持:C语言是一种具有广泛应用的语言,可以在多个操作系统上运行。

代码实现1. 员工信息结构体定义struct Employee {int id; // 员工编号char name[20]; // 员工姓名float basicSalary; // 员工基本工资float performanceBonus; // 绩效奖金float salary; // 员工工资};2. 添加新员工信息函数void addEmployee(struct Employee *employee, int num) {printf("请输入员工编号:");scanf("%d", &(employee[num].id));// 输入其他员工信息...}3. 更新员工信息函数void updateEmployee(struct Employee *employee, int id) {int i;for (i = 0; i < num; i++) {if (employee[i].id == id) {// 更新员工信息...}}}4. 计算员工工资函数void calculateSalary(struct Employee *employee, int num) {int i;for (i = 0; i < num; i++) {employee[i].salary = employee[i].basicSalary + employee[i].performance Bonus;}}5. 发放工资函数void paySalary(struct Employee *employee, int num) {int i;for (i = 0; i < num; i++) {printf("员工编号:%d,工资:%.2f\n", employee[i].id, employee[i].salar y);}}6. 查询员工信息函数void searchEmployee(struct Employee *employee, int id) {int i;for (i = 0; i < num; i++) {if (employee[i].id == id) {// 输出员工信息...}}}7. 统计工资情况函数void statisticsSalary(struct Employee *employee, int num) { float totalSalary = 0;int i;for (i = 0; i < num; i++) {totalSalary += employee[i].salary;}printf("总工资:%f\n", totalSalary);}使用示例1. 添加员工信息struct Employee employees[100];int num = 0;addEmployee(employees, num);num++;2. 更新员工信息int id = 12345;updateEmployee(employees, id);3. 计算员工工资calculateSalary(employees, num);4. 发放工资paySalary(employees, num);5. 查询员工信息int id = 12345;searchEmployee(employees, id);6. 统计工资情况statisticsSalary(employees, num);总结本文介绍了一个基于C语言的职工工资管理系统代码。

工资管理系统源代码

工资管理系统源代码

#include <stdio.h>#include <string.h>#include <ctype.h>#include <stdlib.h>#include <windows.h>#define MONTH_NUM 5 /* 最多的月份*/struct worker{int number; /* 每个工人的工号*/char name[15]; /* 每个工人的姓名*/int salary[MONTH_NUM]; /* 每个工人M月的工资*/ int sum; /* 每个工人的总工资*/ float average; /* 每个工人的平均工资*/ struct worker *next; //下一个节点的地址};typedef struct worker STU;char Menu(void);int Ascending(int a, int b);int Descending(int a, int b);void IntSwap(int *pt1, int *pt2);void CharSwap(char *pt1, char *pt2);void FloatSwap(float *pt1, float *pt2);STU *AppendNode(STU *head, const int m);STU *DeleteNode(STU *head, int nodeNum);STU *ModifyNode(STU *head, int nodeNum, const int m); STU *SearchNode(STU *head, int nodeNum);STU *Appendsalary(STU *head, const int m);void Totalsalary(STU *head, const int m);void Printsalary(STU *head, const int m);STU *Deletesalary(STU *head, const int m);void Modifysalary(STU *head, const int m);void Sortsalary(STU *head, const int m, int (*compare)(int a, int b));void Searchsalary(STU *head, const int m);void DeleteMemory(STU *head);void numberSwap(STU *head);main(){char ch,b;int m,a;STU *head = NULL;printf("\n\n\n\n\n\n\n\n\n");printf("``╭╮╭╮╭╮\n");printf("``│││││└╮\n");printf("╭┴┴———————┴┴╮~└—╯\n");printf("││╭—————╮\n");printf("│││哈│\n");printf("│●●│╭╮│喽! │\n");printf("│○╰┬┬┬╯○│o╰╯╰—————╯\n");printf("│╰—╯│\n");printf("╰——┬o———o┬——╯\n");printf(" ╭╮╭╮\n");printf(" ╰┴————┴╯\n");Sleep(3000);system("cls");printf("\n\n\n\n\n\n\n\n\n\n\n ≈~☆输入要记录的月份个数(m<10)☆~~`≈: "); scanf("%d", &m);system("cls");while (1){ch = Menu();switch (ch){case'1':head = Appendsalary(head, m);Totalsalary(head, m);break;case'2':Modifysalary(head, m);Totalsalary(head, m);printf("\nAfter modified\n");Printsalary(head, m);Sleep(1000);break;case'3':head = Deletesalary(head, m);printf("\nAfter deleted\n");Printsalary(head, m);break;case'4':do{Searchsalary(head, m);printf("\(≧▽≦)/ 是否要继续查询?Y or N:");scanf(" %c",&b);}while(b=='y'||b=='Y');break;case'5':Printsalary(head, m);printf("\(≧▽≦)/ 是否要选择排列方式?Y or N:");scanf(" %c",&b);while(b=='y'||b=='Y'){printf("你想降序排列还是升序排列?(1降序2升序):");scanf(" %d",&a);if(a==1){Sortsalary(head, m, Descending);printf("\nsorted in descending order by sum\n");Printsalary(head, m);}else{Sortsalary(head, m, Ascending);printf("\nsorted in ascending order by sum\n");Printsalary(head, m);}printf("O(∩_∩)O 是否继续选择排列方式?Y or N:");scanf(" %c",&b);}break;case'0':system("cls");printf("┴┬┴┬/ ̄\_/ ̄\\n");printf("┬┴┬┴▏▏▔▔▔▔\\n");printf("┴┬┴/\/﹨\n");printf("┬┴∕/)╭—————╮\n"); printf("┴┬▏●▏│再│\n"); printf("┬┴▏▔█◤╭╮│见! │\n"); printf("┴◢██◣\__/o╰╯╰—————╯\n"); printf("┬█████◣/\n");printf("┴█████████████◣\n");printf("◢██████████████▆▄\n");printf("◢██████████████▆▄\n");printf("█◤◢██◣◥█████████◤\\n");printf("◥◢████████████◤\\n");printf("┴███████████◤﹨\n");printf("┬││█████◤▏\n");printf("┴││)\n");printf("┬∕∕/▔▔▔\∕\n");printf("*∕___/﹨∕\/\\n");printf("┬┴┬┴┬┴\\_ ﹨/﹨\n");printf("┴┬┴┬┴┬┴\___\﹨/▔\﹨\n");exit(0);DeleteMemory(head);printf("End of program!");break;default:printf("Input error!");break;}}}char Menu(void)//主菜单{char ch;system("cls");printf("\n\n\n\n ━━●●━━━━━━━━━━━管理工人的工资━━━━━━...........(╯3╰)\n");printf(" 1.添加记录\n");printf(" 2.更新记录\n");printf(" 3.删除记录\n");printf(" 4.查询记录\n");printf(" 5.统计分析记录\n");printf(" 0.退出\n");printf(" ━━━━━━━━━━☆━━━━━━━━━━━━━━━━━☆━━━━━━━━━━\n");printf("` `.~ ☆~~`≈~☆☆~~`≈~☆☆~~`≈~☆.` `.~\n");printf("\n请输入你的选择:");scanf(" %c", &ch); /*在%c前面加一个空格,将存于缓冲区中的回车符读入*/system("cls");return ch;}STU *Appendsalary(STU *head, const int m)//添加新记录{int i = 0;char c;do{head = AppendNode(head, m); /*向链表末尾添加一个节点*/printf("\n O(∩_∩)O 你想再添加一个新的记录吗(Y/N)?");scanf(" %c",&c); /*%c前面有一个空格*/i++;}while (c=='Y' || c=='y');printf("%d new nodes have been apended!\n", i);return head;}STU *Deletesalary(STU *head, const int m)//删除记录{int i = 0, nodeNum;char c;do{printf("\n ⊙﹏⊙请输入你想删除的记录编号:");scanf("%d", &nodeNum);head = DeleteNode(head, nodeNum); /*删除工号为nodeNum的工人信息*/ Printsalary(head, m); /*显示当前链表中的各节点信息*/printf("Do you want to delete a node(Y/N)?");scanf(" %c",&c); /*%c前面有一个空格*/i++;}while (c=='Y' || c=='y');printf("%d nodes have been deleted!\n", i);return head;}void Modifysalary(STU *head, const int m)//修改记录{int i = 0, nodeNum;char c;do{printf("\n~~~^_^~~~ 请输入你想修改的记录编号:");scanf("%d", &nodeNum);head = ModifyNode(head, nodeNum, m); /*修改工号为nodeNum的节点*/ printf("Do you want to modify a node(Y/N)?");scanf(" %c",&c); /*%c前面有一个空格*/ i++;}while (c=='Y' || c=='y');printf("%d nodes have been modified!\n", i);}void Totalsalary(STU *head, const int m){STU *p = head;int i;while (p != NULL) /*若不是表尾,则循环*/{p->sum = 0;for (i=0; i<m; i++){p->sum += p->salary[i];}p->average = (float)p->sum / m;p = p->next; /*让p指向下一个节点*/}}void Sortsalary(STU *head, const int m, int (*compare)(int a, int b)){STU *pt;int flag = 0, i;do{flag = 0 ;pt = head;/*若后一个节点的总工资比前一个节点的总工资高,则交换两个节点中的数据注意只交换节点数据,而节点顺序不变,即节点next指针内容不进行交换*/ while (pt->next != NULL){if ((*compare)(pt->next->sum, pt->sum)){IntSwap(&pt->number, &pt->next->number);CharSwap(pt->name, pt->next->name);for (i=0; i<m; i++){IntSwap(&pt->salary[i], &pt->next->salary[i]);}IntSwap(&pt->sum, &pt->next->sum);FloatSwap(&pt->average, &pt->next->average);flag = 1;}pt = pt->next;}}while(flag);}/*交换两个整型数*/void IntSwap(int *pt1, int *pt2){int temp;temp = *pt1;*pt1 = *pt2;*pt2 = temp;}/*交换两个实型数*/void FloatSwap(float *pt1, float *pt2){float temp;temp = *pt1;*pt1 = *pt2;*pt2 = temp;}/*交换两个字符串*/void CharSwap(char *pt1, char *pt2){char temp[15];strcpy(temp, pt1);strcpy(pt1, pt2);strcpy(pt2, temp);}/*决定数据是否按升序排序,a<b为真,则按升序排序*/ int Ascending(int a, int b){return a < b;}/* 决定数据是否按降序排序,a>b为真,则按降序排序*/ int Descending(int a, int b){return a > b;}void Searchsalary(STU *head, const int m)//查询记录{int number, i,j,k=0,x,t=0;char str[100] = {'\0'}, temp[3];STU *findNode;printf("\n 请输入你想查找的记录编号:");scanf("%d", &number);findNode = SearchNode(head, number);if (findNode == NULL){printf("Not found!\n");}else{strcat(str, "工号");for(j=0;j<=strlen(findNode->name);j++)strcat(str," ");strcat(str, "姓名");for (i=1; i<=m; i++){if(findNode->salary[i]/10) t++;for(x=0;x<2*t;x++)strcat(str," ");strcat(str, "工资");itoa(i,temp, 10);strcat(str, temp);}strcat(str," 已发工资总和");if(findNode->sum/10) k++;for(i=0;i<k;i++)strcat(str," ");strcat(str," 个人平均工资");printf("%s", str);printf("\nNo.%3d %-8s ", findNode->number, findNode->name); for (i=0; i<m; i++){printf("%-7d ", findNode->salary[i]);}printf("%9d %9.2f\n", findNode->sum, findNode->average);}}void Printsalary(STU *head, const int m){STU *p = head;char str[100] = {'\0'}, temp[3];int i, j = 1,k,x,n=0,t=0;strcat(str, "工号");for(k=0;k<=strlen(p->name);k++)strcat(str," ");strcat(str, "姓名");for (i=1; i<=m; i++){if(p->salary[i]/10) t++;for(x=0;x<2*t;x++)strcat(str," ");strcat(str, "工资");itoa(i,temp, 10);strcat(str, temp);}strcat(str," 已发工资总和");if(p->sum/10) n++;for(k=0;k<n;k++)strcat(str," ");strcat(str," 个人平均工资");printf("%s", str); /* 打印表头*/while (p != NULL) /*若不是表尾,则循环打印*/{printf("\nNo.%3d %-8s ", p->number, p->name);for (i=0; i<m; i++){printf("%-7d ", p->salary[i]);}printf("%9d %9.2f\n", p->sum, p->average);p = p->next; /*让p指向下一个节点*/j++;}printf("\n");}STU *AppendNode(STU *head, const int m){STU *p = NULL;STU *pr = head;int j;p = (STU *)malloc(sizeof(STU)); /*为新添加的节点申请内存*/if (p == NULL) /*若申请内存失败,则打印错误信息,退出程序*/ {printf("No enough memory to alloc");exit(0);}if (head == NULL) /*若原链表为空表,则将新建节点置为首节点*/ {head = p;}else /*若原链表为非空,则将新建节点添加到表尾*/{/*若未到表尾,则继续移动指针pr,直到pr指向表尾*/while (pr->next != NULL){pr = pr->next;}pr->next = p; /*将新建节点添加到链表的末尾*/}pr = p; /*让pr指向新建节点*/printf("Input node data......");printf("\nInput number:");scanf("%d", &p->number);printf("Input name:");scanf("%s", p->name);for (j=0; j<m; j++){printf("Input salary%d:", j+1);scanf("%d", p->salary+j);}pr->next = NULL; /*将新建节点置为表尾*/return head; /*返回添加节点后的链表的头节点指针*/ }STU *ModifyNode(STU *head, int nodeNum, const int m){int j;STU *newNode;newNode = SearchNode(head, nodeNum);if (newNode == NULL){printf("Not found!\n");}else{printf("Input the new node data:\n");printf("Input name:");scanf("%s", newNode->name);for (j=0; j<m; j++){printf("Input salary%d:", j+1);scanf("%d", newNode->salary+j);}}return head;}STU *DeleteNode(STU *head, int nodeNum){STU *p = head, *pr = head;if (head == NULL) /*链表为空,没有节点,无法删除节点*/{printf("No Linked Table!\n");return(head);}/*若没找到节点nodeNum且未到表尾,则继续找*/while (nodeNum != p->number && p->next != NULL){pr = p;p = p->next;}if (nodeNum == p->number) /*若找到节点nodeNum,则删除该节点*/{if (p == head) /*若待删节点为首节点,则让head指向第2个节点*/{head = p->next;}else /*若待删节点非首节点,则将前一节点指针指向当前节点的下一节点*/ {pr->next = p->next;}free(p); /*释放为已删除节点分配的内存*/}else /*没有找到待删除节点*/{printf("This Node has not been found!\n");}return head; /*返回删除节点后的链表的头节点指针*/}STU *SearchNode(STU *head, int nodeNum){STU *p = head;int j = 1;while (p != NULL) /*若不是表尾,则循环*/{if (p->number == nodeNum) return p;p = p->next; /*让p指向下一个节点*/j++;}return NULL;}void DeleteMemory(STU *head){STU *p = head, *pr = NULL;while (p != NULL) /*若不是表尾,则释放节点占用的内存*/ {pr = p; /*在pr中保存当前节点的指针*/p = p->next; /*让p指向下一个节点*/free(pr); /*释放pr指向的当前节点占用的内存*/}}。

员工薪资管理系统课程设计

员工薪资管理系统课程设计

员工薪资管理系统课程设计学院:班级:学号:姓名:余黎晨李雪敏敬翰林颜学宏指导教师:李竹林目录一:绪论1.1设计目的1.2设计内容1.3开发背景1.4开发环境1.5组内成员及分工二:需求分析2.1题目分析2.2功能分析2.3数据流图2.4数据字典2.5系统功能三:系统分析与设计3.1概念结构设计3.2逻辑结构设计3.3 物理结构设计四:数据库实施及运行4.1建基本表4.3功能实现4.4完整代码五:设计心得及体会一:绪论1.1设计目的员工薪资系统的主要目的是通过操作计算机代替手工劳动,能够在该系统内完成员工的信息录入,查询,删除等操作,方便公司的高效化,规范化管理,有利于员工更好更方便了解自己的薪资信息。

系统开发的总体任务就是实现员工薪资管理的系统化、规范化和自动化。

1.2设计内容题目6:员工薪资管理1)背景资料a)某单位现有1000名员工,其中有管理人员、财务人员、技术人员和销售人员。

b)该单位下设4个科室,即经理室、财务科、技术科和销售科。

c)工资由基本工资、福利补贴和奖励工资构成,失业保险和住房公积金在工资中扣除。

d)每个员工的基本资料有姓名、性别、年龄、单位和职业(如经理、工程师、销售员等)。

e)每月个人的最高工资不超过3000元。

工资按月发放,实际发放的工资金额为工资减去扣除。

2)设计要求:a)进行需求分析,编写数据字典。

b)设计E-R图。

c)实现按照科室录入个人的基本资料、工资和扣除金额的数据。

d)计算个人的实际发放工资。

e)按科室、职业分类统计人数和工资金额。

f)实现分类查询。

g)能够删除辞职人员的数据。

h)开发工具不限。

1.3开发背景当今社会,随着企业人数的不断增加,企业员工薪资的管理工作也越来越复杂,资金是企业生存的核心部分,而资金流动也是关键环节,随着计算机的普及,计算机管理系统已经原来越来越广泛的应用于各个中小型企业中,用计算机取代手工对企业管理的操作也是势在必行的,并且人为操作容易造成信息错误,纸质材料不易保存,可能会导致企业运转出现滞缓现象,影响企业发展。

c语言课程设计职工工资管理系统源代码

c语言课程设计职工工资管理系统源代码

c语言课程设计职工工资管理系统源代码This manuscript was revised by the office on December 22, 2012绝对可以完美运行,下面有运行图片#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");|\n");printf("| 3 职工信息查询|\n");printf("| |\n");printf("| 4 职工信息修改|\n");printf("| |\n");printf("| 5 工资排序|\n");printf("| |\n");printf("| 6 工资统计|\n");printf("| |\n");printf("| 0 退出|\n");|\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].employ eeid,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].employ eeid,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].employ eeid,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].employ eeid,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].employ eeid,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].employ eeid,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工资管理系统源代码

}
/*插入模块*/
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语言职工工资管理系统代码

c语言职工工资管理系统代码C语言职工工资管理系统是一款可以帮助企业管理职工工资信息的软件。

它可以实现职工信息的录入、查询、修改和删除等功能,同时还可以计算出每个职工的工资和提供相应的统计报表,为企业的工资管理工作提供了便利。

首先,C语言职工工资管理系统需要职工信息的录入。

通过该系统,企业可以方便地将新聘职工的基本信息录入,包括姓名、部门、岗位、入职时间等。

录入信息的过程简单便捷,只需要输入相应的信息即可完成。

其次,该系统具备职工信息的查询功能。

企业可以通过系统快速准确地查询任意一位职工的相关信息,包括姓名、部门、岗位、入职时间等。

职工信息的查询非常方便,只需要输入相应的关键词即可找到相应的结果。

除此之外,C语言职工工资管理系统还支持职工信息的修改和删除。

当职工的个人信息发生变化时,企业可以通过该系统对职工信息进行修改,保证信息的及时更新。

而如果某位职工离职或换岗,企业也可以通过系统将其信息进行删除,做到数据库的动态管理。

另外,C语言职工工资管理系统还具备工资计算的功能。

系统可以根据职工的薪资方案和考勤情况,自动计算出每个职工的工资。

这不仅提高了工资计算的准确性和效率,也减轻了人力资源部门的工作压力。

同时,该系统还能为企业提供详尽的工资统计报表。

企业可以通过系统生成工资明细表、部门工资汇总表、岗位工资统计表等各种报表,方便了企业对工资情况的分析和统计。

这些报表可以提供给管理层,帮助他们做出更加科学合理的决策。

综上所述,C语言职工工资管理系统是一款功能全面、使用便捷的软件。

它不仅可以方便地管理企业的职工信息,还可以快速准确地计算出职工的工资,并生成相应的统计报表。

对于现代企业来说,这样一款工资管理系统无疑是一项非常重要的工具,它可以提高工资管理的效率和准确性,减轻企业管理层的负担,为企业的发展提供有力的支持。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档