您好,登錄后才能下訂單哦!
小編給大家分享一下如何使用C語言實(shí)現(xiàn)簡單員工工資管理系統(tǒng),希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
具體內(nèi)容如下
1、公司主要有經(jīng)理、技術(shù)員、銷售員、銷售經(jīng)理4類崗位人員,他們都有基本信息:職工號(hào)、姓名、性別、部門、崗位、工齡、當(dāng)月工資等。一個(gè)部門最多只能有一個(gè)銷售經(jīng)理,一個(gè)部門可以有多個(gè)銷售員,一個(gè)部門可以有若干個(gè)經(jīng)理和若干技術(shù)員。
2、員工數(shù)據(jù)包括基本資料數(shù)據(jù)和工資數(shù)據(jù)兩部分,員工基本資料數(shù)據(jù)包括職工號(hào)、姓名、性別、部門、崗位、工齡;員工工資數(shù)據(jù)包括工作時(shí)間、小時(shí)工資、銷售額、底薪、當(dāng)月工資。
3、員工當(dāng)月工資的計(jì)算辦法。
A.經(jīng)理:底薪(8000)+工齡×35;
B.技術(shù)員:工作時(shí)間×小時(shí)工資(100元每小時(shí))+工齡×35;
C.銷售員:銷售額×4%提成+工齡×35;
D.銷售經(jīng)理:底薪(8000)+所轄部門銷售額總額×0.5%+工齡×35。
現(xiàn)在需要開發(fā)一個(gè)公司員工工資管理系統(tǒng)對(duì)員工工資進(jìn)行有效管理。
數(shù)據(jù)維護(hù)管理:要求對(duì)員工的基本資料數(shù)據(jù)和工資數(shù)據(jù)分開管理?;举Y料數(shù)據(jù)的維護(hù)管理功能包括添加(批量、單個(gè))、修改、刪除、查詢等;工資數(shù)據(jù)的維護(hù)管理功能包括輸入(批量、單個(gè))、修改、刪除、查詢等。
A. 基本資料數(shù)據(jù)的維護(hù)管理
(1).添加:(批量、單個(gè))添加員工基本資料數(shù)據(jù)?;举Y料數(shù)據(jù)包括職工號(hào)、姓名、性別、部門、崗位、工齡。
(2).修改:根據(jù)職工號(hào)來修改任意員工的除職工號(hào)外的其他基本資料數(shù)據(jù)。
(3).刪除:根據(jù)職工號(hào)刪除一個(gè)員工。
(4).查詢:根據(jù)職工號(hào)查詢一個(gè)員工的基本資料數(shù)據(jù)。
B. 工資數(shù)據(jù)的維護(hù)管理
(1).輸入:(批量、單個(gè))輸入員工工資數(shù)據(jù)。工資數(shù)據(jù)根據(jù)員工類型的不同而有區(qū)別,輸入的相關(guān)數(shù)據(jù)也應(yīng)不同。注意:當(dāng)月工資是計(jì)算項(xiàng),不能輸入。
(2).修改:根據(jù)職工號(hào)來修改任意員工的相關(guān)工資數(shù)據(jù)(注意:不同類別員工相關(guān)數(shù)據(jù)不同)。
(3).刪除:根據(jù)職工號(hào)刪除一個(gè)員工(不能刪除,只需將相關(guān)數(shù)據(jù)項(xiàng)設(shè)置成-1)。
(4).查詢:根據(jù)職工號(hào)查詢一個(gè)員工的工資數(shù)據(jù)。
(5).計(jì)算:批量計(jì)算所有技術(shù)員、銷售員和銷售經(jīng)理的當(dāng)月工資額。注意,① 銷售經(jīng)理所轄部門銷售額總額為本部門所有銷售員當(dāng)月銷售額之和。② 只有各項(xiàng)數(shù)據(jù)都為有效數(shù)據(jù)時(shí)(-1為無效數(shù)據(jù)),才能計(jì)算。
查詢數(shù)據(jù)
分頁顯示全部員工的信息。分頁功能:每頁顯示10條員工的信息,有上一頁、下一頁、首頁和最后一頁的功能。
按部門顯示本部門全部員工信息。注意:無需分頁顯示。
分類顯示4種崗位的員工信息。注意:無需分頁顯示。
根據(jù)工號(hào)或者姓名查詢員工信息。
排序:
所有員工信息按當(dāng)月工資從高到低排序并顯示。注意:無需分頁顯示。
某個(gè)崗位的員工信息按當(dāng)月工資從高到低排序并顯示。注意:無需分頁顯示。
統(tǒng)計(jì):
1、統(tǒng)計(jì)并顯示某個(gè)部門的平均工資、最低工資、最高工資。
2、統(tǒng)計(jì)并顯示某個(gè)部門超出平均工資的人數(shù)與員工信息。注意:無需分頁顯示。
3、統(tǒng)計(jì)并顯示所有員工中的最低工資和最高工資員工的信息。
4、統(tǒng)計(jì)并顯示所有員工超出平均工資的人數(shù)與員工信息。注意:無需分頁顯示。
1、員工用結(jié)構(gòu)體表示,全體員工用一個(gè)鏈表來表示。某一崗位的員工,可以只使用員工結(jié)構(gòu)體的部分成員,比如:經(jīng)理只使用基本信息成員,而不使用銷售額成員、工作時(shí)間成員。
2、必須用文件來存儲(chǔ)員工信息:開始運(yùn)行程序時(shí)從文件中讀取員工信息到鏈表,退出程序時(shí)將員工信息保存到文件中。
3、主菜單有一個(gè)菜單項(xiàng)能夠?qū)T工信息保存到文件。
4、數(shù)據(jù)約束:
1)、職工號(hào):整型、不能重復(fù)、從1開始依次遞增、由軟件自動(dòng)計(jì)算產(chǎn)生,不能修改。
2)、崗位:枚舉類型,分別表示經(jīng)理、技術(shù)員、銷售員、銷售經(jīng)理。
3)、員工的其他信息不能為空。
4)、其他:至少有兩層菜單。
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct employee{ int num; /* 工號(hào) */ char name[20]; /* 姓名 */ int sex; /* 性別 1 man 2 madam*/ int department; /* 部門 */ int post; /* 1為經(jīng)理、2為技術(shù)員、3為銷售員、4為銷售經(jīng)理 */ int lengthservice; /* 工齡 */ int hour; /* 工作時(shí)間 */ int hoursalary; /* 時(shí)薪*/ int sales; /* 銷售額*/ int basicsalary; /* 底薪*/ int salary; /* 工資總數(shù)*/ struct employee *next; }employee; struct Employee{ int num; char name[20]; /* 姓名 */ int sex; /* 性別 1 man 2 madam*/ int department; /* 部門 */ int post; /* 1為經(jīng)理、2為技術(shù)員、3為銷售員、4為銷售經(jīng)理 */ int lengthservice; /* 工齡 */ int hour; /* 工作時(shí)間 */ int hoursalary; /* 時(shí)薪*/ int sales; /* 銷售額*/ int basicsalary; /* 底薪*/ int salary; /* 工資總數(shù)*/ }; void main() { int num=0,flag,a,NUM; char name[20]; employee *list,*rare;//頭節(jié)點(diǎn)list無數(shù)據(jù) 尾指針rare有數(shù)據(jù) int increase(employee *rare,int *num); void DecendOrder(employee *list); void Statistics(employee *list); void queryAll(employee *list); void querybasic(employee *list,int num); void Delete(employee *list,int num); void DeleteSalary(employee *list,int num); void querysalary(employee *list,int num); void change(employee *list,int num); void changesalary(employee *list,int num); void Statistics2(employee *list); void querynum(employee *list,int num); employee *import(employee *list,int *num); void salary(employee *list); void Statistics3(employee *list); void Statistics4(employee *list); void save(employee *list); void queryname(employee *list,char name[20]); void querydepart(employee *list,int num); void querypost(employee *list); void DecendOrder2(employee *list); list=(employee *)malloc(sizeof(employee)); list->next=NULL; rare=import(list,&num); if(num==0) increase(list,&num); salary(list); while(1) { begin:printf("菜單:添加數(shù)據(jù):1 修改數(shù)據(jù):2 刪除數(shù)據(jù):3 查詢數(shù)據(jù):4 保存數(shù)據(jù):5 統(tǒng)計(jì)數(shù)據(jù):6 數(shù)據(jù)排序:7 退出:0\n"); scanf("%d",&flag); if(flag==0){ save(list); exit(0);} switch(flag){ case 1:increase(rare,&num);salary(list);save(list);break; case 2:printf("修改基本信息:1 修改工資信息:2 返回:0\n");scanf("%d",&a); switch(a){ case 0:goto begin;break; case 1:printf("請(qǐng)輸入要修改的工號(hào)\n");scanf("%d",&NUM);change(list,NUM);break; case 2:printf("請(qǐng)輸入要修改的工號(hào)\n");scanf("%d",&NUM);changesalary(list,NUM);break; }break; case 3:printf("刪除基本信息:1 刪除工資信息:2 返回:0\n");scanf("%d",&a); switch(a){ case 0:goto begin;break; case 1:printf("請(qǐng)輸入要?jiǎng)h除的工號(hào)\n");scanf("%d",&NUM);Delete(list,NUM);break; case 2:printf("請(qǐng)輸入要?jiǎng)h除的工號(hào)\n");scanf("%d",&NUM);DeleteSalary(list,NUM);break; }break; case 4:printf("查詢基本信息:1 查詢工資信息:2 查詢?nèi)啃畔?3 查詢部門信息:4 查詢各個(gè)崗位信息:5 工號(hào)查詢信息:6 姓名查詢信息:7 返回:0\n");scanf("%d",&a); switch(a){ case 0:goto begin;break; case 1:printf("請(qǐng)輸入要查詢的工號(hào)\n");scanf("%d",&NUM);querybasic(list,NUM);break; case 2:printf("請(qǐng)輸入要查詢的工號(hào)\n");scanf("%d",&NUM);querysalary(list,NUM);break; case 3:queryAll(list);break; case 4:printf("請(qǐng)輸入要查詢的部門號(hào)\n");scanf("%d",&NUM);querydepart(list,NUM);break; case 5:querypost(list);break; case 6:printf("請(qǐng)輸入要查詢的工號(hào)\n");scanf("%d",&NUM);querynum(list,NUM);break; case 7:printf("請(qǐng)輸入想查詢的姓名\n");scanf("%s",name);queryname(list,name);break; }break; case 5:save(list);break; case 6:printf("統(tǒng)計(jì)部門平均工資,最低,最高工資:1 統(tǒng)計(jì)部門超過平均工資的人數(shù)與員工信息:2\n統(tǒng)計(jì)所有員工最低工資和最高工資員工的信息:3 統(tǒng)計(jì)所有員工超出平均工資的人數(shù)與員工信息:4\n 返回:0\n");scanf("%d",&a); switch(a){ case 0:goto begin;break; case 1:Statistics(list);break; case 2:Statistics2(list);break; case 3:Statistics3(list);break; case 4:Statistics4(list);break; }break; case 7:DecendOrder2(list);break; default:printf("輸入錯(cuò)誤");goto begin;}} } int increase(employee *rare,int *num)//添加數(shù)據(jù) { employee *p,*q; char name[20]; int sex,department,post,lengthservice,hour,hoursalary,sales,basicsalary; q=rare; printf("請(qǐng)輸入姓名,性別(1為男,2為女),部門,職位(1為經(jīng)理、2為技術(shù)員、3為銷售員、4為銷售經(jīng)理),工齡,工作時(shí)間,時(shí)薪,銷售額,底薪:(工時(shí)為-1時(shí)停止輸入)\n"); scanf("%s%d%d%d%d%d%d%d%d",name,&sex,&department,&post,&lengthservice,&hour,&hoursalary,&sales,&basicsalary); while(hour!=-1) { num++; p=(employee *)malloc(sizeof(employee)); strcpy(p->name,name); p->num=*num; p->sex=sex; p->department=department; p->post=post; p->lengthservice=lengthservice; p->hour=hour; p->hoursalary=hoursalary; p->sales=sales; p->basicsalary=basicsalary; if(*num==1) rare->next=p; else q->next=p; q=p; p->next=NULL; scanf("%s%d%d%d%d%d%d%d%d",name,&sex,&department,&post,&lengthservice,&hour,&hoursalary,&sales,&basicsalary); } return *num; } void salary(employee *list)//計(jì)算工資 { employee *p=list->next,*q=list->next; int sales=0; while(p!=NULL) { if(p->hour==-1)p=p->next; if(p->post==3) p->salary=p->sales*4/100+35*p->lengthservice; else if(p->post==2) p->salary=100*p->hour+35*p->lengthservice; else if(p->post==1) p->salary=8000+p->lengthservice*35; else if(p->post==4){ while(q!=NULL) { if(q->post==3&&q->department==p->department) sales+=q->sales; q=q->next; } p->salary=sales*5/1000+8000+p->lengthservice*35; q=list->next;} p=p->next; } } void querybasic(employee *list,int num)//查詢基本信息 { employee *p; p=list->next; while(p->num!=num&&p!=NULL) p=p->next; if(p->num==num){ printf("工號(hào) 名字 性別 部門 職位 工齡\n"); printf("%-5d%-5s%-5d%-5d%-5d%-5d\n",p->num,p->name,p->sex,p->department,p->post,p->lengthservice);} if(p==NULL) printf("該工號(hào)不存在\n"); } void querysalary(employee *list,int num)//查詢工資信息 { employee *p; p=list->next; while(p->num!=num&&p!=NULL) p=p->next; if(p->num==num){ printf("工號(hào) 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); printf("%-6d%-6d%-6d%-8d%-6d%-6d\n",p->num,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary);} if(p==NULL) printf("該工號(hào)不存在\n"); } void Delete(employee *list,int num)//刪除基本信息 { employee *p,*q; p=list->next; q=p->next; while(p->next->num!=num) { p=p->next; q=p->next; } if(q->num==num) p->next=q->next; else printf("職工號(hào)在范圍外"); q=q->next; while(q!=NULL) { q->num--; q=q->next; } } void DeleteSalary(employee *list,int num)//刪除工資信息 { employee *p; p=list->next; while(p->num!=num) p=p->next; if(p->num==num){ p->hour=-1; p->hoursalary=-1; p->sales=-1; p->basicsalary=-1;} else printf("該工號(hào)超出范圍"); } employee *import(employee *list,int *num)//讀取文件 { FILE *fp; struct Employee stu; employee *q,*p; if((fp=fopen("employee.dat","rb"))==NULL){ printf("文件不存在,輸入數(shù)據(jù)以建立一個(gè)文件存儲(chǔ)信息\n"); return 0;} q=(employee *)malloc(sizeof(employee)); while(!feof(fp)) { if((fread(&stu,sizeof(struct Employee),1,fp))!=1)break; *num=*num+1; p=(employee *)malloc(sizeof(employee)); strcpy(p->name,stu.name); p->num=*num; p->sex=stu.sex; p->department=stu.department; p->post=stu.post; p->lengthservice=stu.lengthservice; p->hour=stu.hour; p->hoursalary=stu.hoursalary; p->sales=stu.sales; p->basicsalary=stu.basicsalary; p->salary=stu.salary; if(*num==1) list->next=p; else q->next=p; q=p; p->next=NULL; } fclose(fp); return q; } void save(employee *list)//存儲(chǔ)到文件 { struct Employee stu; FILE *fp; employee *p; p=list->next; if((fp=fopen("employee.dat","wb"))==NULL){ printf("error"); exit(0);} while(p!=NULL) { stu.num=p->num; strcpy(stu.name,p->name); stu.sex=p->sex; stu.department=p->department; stu.post=p->post; stu.lengthservice=p->lengthservice; stu.hour=p->hour; stu.hoursalary=p->hoursalary; stu.sales=p->sales; stu.basicsalary=p->basicsalary; stu.salary=p->salary; if((fwrite(&stu,sizeof(struct Employee),1,fp))!=1)printf("error"); p=p->next; } fclose(fp); } void change(employee *list,int num)//改變基本數(shù)據(jù) { char name[20]; int sex,department,post,lengthservice; employee *p=list->next; while(p->num!=num&&p->next!=NULL) p=p->next; if(p->num==num){ printf("請(qǐng)輸入修改后的姓名 性別 部門 崗位 工齡\n"); scanf("%s%d%d%d%d",name,&sex,&department,&post,&lengthservice); strcpy(p->name,name); p->sex=sex; p->department=department; p->post=post; p->lengthservice=lengthservice;} else printf("職工號(hào)超出范圍"); } void changesalary(employee *list,int num)//改變工資數(shù)據(jù) { int hour,hoursalary,sales,basicsalary; employee *p=list->next; while(p->num!=num) p=p->next; if(p->num==num){ printf("請(qǐng)輸入修改后的工作時(shí)間 小時(shí)工資 銷售額 底薪 \n"); scanf("%d%d%d%d",&hour,&hoursalary,&sales,&basicsalary); p->hour=hour; p->hoursalary=hoursalary; p->sales=sales; p->basicsalary=basicsalary;} else printf("職工號(hào)超出范圍"); } void queryAll(employee *list)//分頁查詢所有信息 { employee *p,*page[100]; int n,i,top=0,flag=0,max; p=list->next; while(p!=NULL) { page[++top]=p; i=1; while(i<=10) { i++; p=p->next; if(p==NULL)break; } } max=top; top=0; p=page[++top]; printf("工號(hào) 姓名 性別 部門 崗位 工齡 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); while(1) { i=1; while(i<=10) { i++; printf("%-5d%-5s%-5d%-5d%-5d%-5d%-5d%-5d%-7d%-5d%-5d\n",p->num,p->name,p->sex,p->department,p->post,p->lengthservice,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary); p=p->next; if(p==NULL)break; } begin:printf("當(dāng)前頁碼%d 首頁->1 上一頁->2 下一頁->3 尾頁->4 退出->0\n",top); scanf("%d",&n); if(n==0)break; else if(n==1)top=1,p=page[1]; else if(n==2){ if(top==1){ printf("當(dāng)前已經(jīng)是第一頁\n"); goto begin;} else p=page[--top];} else if(n==3){ if(top==max){ printf("當(dāng)前已經(jīng)是最后一頁\n"); goto begin;} else p=page[++top];} else if(n==4)top=max,p=page[max]; else goto begin; } } void querydepart(employee *list,int num)//輸出該部門全部員工信息 { employee *p=list->next; printf("%d部門的全部員工信息為:\n",num); printf("工號(hào) 姓名 性別 部門 崗位 工齡 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); while(p!=NULL) { if(p->department==num) printf("%-5d%-5s%-5d%-5d%-5d%-5d%-5d%-5d%-7d%-5d%-5d\n",p->num,p->name,p->sex,p->department,p->post,p->lengthservice,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary); p=p->next; } } void querypost(employee *list)//分類顯示四個(gè)崗位的員工信息 { employee *p; int i=0; while(i<4) { switch(i){ case 0:printf("經(jīng)理崗位的信息為(若為空則無):\n");break; case 1:printf("技術(shù)員崗位的信息為(若為空則無):\n");break; case 2:printf("銷售員崗位的信息為(若為空則無):\n");break; case 3:printf("銷售經(jīng)理崗位的信息為(若為空則無):\n");break; } p=list->next; i++; while(p!=NULL) { if(p->post==i) printf("%d %s %d %d %d %d %d %d %d %d %d\n",p->num,p->name,p->sex,p->department,p->post,p->lengthservice,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary); p=p->next; } } } void querynum(employee *list,int num)//工號(hào)查詢個(gè)人全部信息 { employee *p; p=list->next; while(p!=NULL) { if(p->num==num) break; p=p->next; } if(p->num==num){ printf("工號(hào) 姓名 性別 部門 崗位 工齡 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); printf("%-5d%-5s%-5d%-5d%-5d%-5d%-5d%-5d%-7d%-5d%-5d\n",p->num,p->name,p->sex,p->department,p->post,p->lengthservice,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary);} else printf("工號(hào)超出范圍"); } void queryname(employee *list,char name[20])//用姓名查詢數(shù)據(jù) { employee *p; p=list->next; while(p!=NULL) { if(strcmp(p->name,name)==0) break; p=p->next; } if(strcmp(p->name,name)==0){ printf("工號(hào) 姓名 性別 部門 崗位 工齡 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); printf("%-5d%-5s%-5d%-5d%-5d%-5d%-5d%-5d%-7d%-5d%-5d\n",p->num,p->name,p->sex,p->department,p->post,p->lengthservice,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary);} else printf("該姓名不存在"); } void Statistics(employee *list) { employee *p=list->next,*q=list->next,*max=list->next,*k; //p,q作為循環(huán)指針,max指針指向最大的 employee *headis=NULL; //用來保存部門的信息 employee *Max,*Min; //最大和最小值的成員 int i=0; //計(jì)算部門的人數(shù); int sum=0,avar=0; //總值,平均值 int department; //用來接收想要統(tǒng)計(jì)的部門 printf("請(qǐng)輸入你想要統(tǒng)計(jì)的部門:\n"); scanf("%d",&department); //提取所要統(tǒng)計(jì)的部門的成員 while(p) { if(p->num==-1) { p=p->next; continue; } if(department==p->department) { q=(employee *)malloc(sizeof(employee)); *q=*p; q->next=NULL; if(!headis) headis=q; else k->next=q; k=q; } p=p->next; } //計(jì)算最大、最小和平均值 p=headis; q=headis; Max=headis; Min=headis; while(p) { if(p->num==-1) { p=p->next; continue; } if(p->salary>Max->salary) Max=p; else if(p->salary<Min->salary) Min=p; sum+=p->salary ; p=p->next; i++; } avar=sum/i; printf("部門:%d\n",department); printf("平均工資:%d\n",avar); printf("最低工資:%d\n",Min->salary); printf("最高工資:%d\n",Max->salary); } void Statistics2(employee *list) { employee *p=list->next,*q=list->next,*max=list->next,*k; //p,q作為循環(huán)指針,max指針指向最大的 employee *headis=NULL; //用來保存部門的信息 int j=0,i=0; //用j來計(jì)算人數(shù),i計(jì)算工資大于平均工資的人數(shù) int sum=0,avar=0; //平均值 int department; //用來接收想要統(tǒng)計(jì)的部門 printf("請(qǐng)輸入你想要統(tǒng)計(jì)的部門:\n"); scanf("%d",&department); //提取所要統(tǒng)計(jì)的部門的成員 while(p!=NULL) { if(p->num==-1) { p=p->next; continue; } if(department==p->department) { j++; q=(employee*)malloc(sizeof(employee)); *q=*p; q->next=NULL; if(!headis) headis=q; else k->next=q; k=q; } p=p->next; } //計(jì)算最大、最小和平均值 p=headis; q=headis; while(p!=NULL) { if(p->num==-1) { p=p->next; continue; } sum+=p->salary ; p=p->next; } avar=sum/j; p=q; headis=0; //提取超過平均工資的部門的成員 while(p!=NULL) { if(p->num==-1) { p=p->next; continue; } if((p->salary)>avar) { i++; q=(employee *)malloc(sizeof(employee)); *q=*p; q->next=NULL; if(!headis) headis=q; else k->next=q; k=q; } p=p->next; } p=headis; printf("部門:%d\n",department); printf("超出平均工資的人數(shù)為:%d\n",i); if(i!=0){ printf("這些成員的信息如下:\n"); printf("工號(hào) 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); while(p!=NULL) { if(p->num==-1) { p=p->next; continue; } printf("%-6d%-6d%-6d%-8d%-6d%-6d\n",p->num,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary); p=p->next ; }} } void Statistics3(employee *list) { employee *Max,*Min; //指向最大和最小值的成員 employee*p=list->next; //p作為循環(huán)指針 Max=list->next; Min=list->next; while(p) { if(p->num==-1) { p=p->next; continue; } if(p->salary >Max->salary ) Max=p; if(p->salary <Min->salary) Min=p; p=p->next; } p=Min; printf("在所有員工中:"); printf("最低工資的員工信息:\n"); printf("工號(hào) 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); printf("%-6d%-6d%-6d%-8d%-6d%-6d\n",p->num,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary); p=Max; printf("最高工資的員工信息:\n"); printf("工號(hào) 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); printf("%-6d%-6d%-6d%-8d%-6d%-6d\n",p->num,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary); } void Statistics4(employee *list) { employee *p=list->next,*q=list->next,*k; //p,q作為循環(huán)指針 employee *headis=0; //用來保存工資超過平均工資的成員 int i=0; //用i來計(jì)算人數(shù) double sum=0,avar=0; //總值,平均值 //求平均值 while(p) { if(p->num==-1) { p=p->next; continue; } i++; sum+=p->salary ; p=p->next; } avar=sum/i; //提取出超過平均工資的成員,并且計(jì)算人數(shù) i=0; p=list; while(p) { if(p->num==-1) { p=p->next; continue; } if(p->salary >avar) { i++; q=(employee *)malloc(sizeof(employee)); *q=*p; q->next=NULL; if(!headis) headis=q; else k->next=q; k=q; } p=p->next; } p=headis; printf("超出平均工資的人數(shù):%d\n",i); printf("工號(hào) 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); while(p) { if(p->num==-1) { p=p->next; continue; } printf("%-6d%-6d%-6d%-8d%-6d%-6d\n",p->num,p->hour,p->hoursalary,p->sales,p->basicsalary,p->salary); p=p->next; } } void DecendOrder(employee *list) { employee *p,*q,*a,*b,*s; int j=0; p=list->next; q=p->next; a=list; b=a->next; while(q!=NULL) { a=list; b=a->next; j=0; while(a!=p) { if(q->salary>b->salary) { p->next=q->next; q->next=b; a->next=q; j=1; break; } a=b; b=b->next; } if(j==1) q=p->next; else{ p=q; q=q->next;} } s=list->next; while(s!=NULL){ printf("工號(hào) 姓名 性別 部門 崗位 工齡 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); printf("%-5d%-5s%-5d%-5d%-5d%-5d%-5d%-5d%-7d%-5d%-5d\n",s->num,s->name,s->sex,s->department,s->post,s->lengthservice,s->hour,s->hoursalary,s->sales,s->basicsalary,s->salary); s=s->next; } } void DecendOrder2(employee *list) { employee *p,*q,*a,*b,*s,*z,*x=NULL,*v,*head; int j=0,post; printf("請(qǐng)輸入崗位\n"); scanf("%d",&post); p=list->next; head=(employee *)malloc(sizeof(employee)); while(p!=NULL) { if(p->post==post){ z=(employee *)malloc(sizeof(employee)); *z=*p; z->next=NULL; if(x==NULL) x=z; else v->next=z; v=z;} p=p->next; } head->next=x; p=x; q=p->next; while(q!=NULL) { a=head; b=a->next; j=0; while(a!=p) { if(q->salary>b->salary) { p->next=q->next; q->next=b; a->next=q; j=1; break; } a=b; b=b->next; } if(j==1) q=p->next; else{ p=q; q=q->next;} } s=head->next; while(s!=NULL){ printf("工號(hào) 姓名 性別 部門 崗位 工齡 工時(shí) 時(shí)薪 銷售額 底薪 工資\n"); printf("%-5d%-5s%-5d%-5d%-5d%-5d%-5d%-5d%-7d%-5d%-5d\n",s->num,s->name,s->sex,s->department,s->post,s->lengthservice,s->hour,s->hoursalary,s->sales,s->basicsalary,s->salary); s=s->next; } }
看完了這篇文章,相信你對(duì)“如何使用C語言實(shí)現(xiàn)簡單員工工資管理系統(tǒng)”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。