1、#include#include#define N 10000 /*员工的最大数*/typedef struct wagefloat wage1; /*员工的基本工资*/float Bonus; /*员工的奖金 */float tax; /*员工的税金*/float S_fee; /*员工的水费*/float D_fee; /*员工的电费*/float T_fee; /*员工的有线电视费*/float Q_fee; /*员工的清洁费 */float S_wage; /*员工的实发工资*/WAGE;typedef struct workerchar name10; /*员工的姓名*/char I
2、D10; /*员工的工号*/int ID_P; /*员工的职务代号 1-高级工程师 2-中级工程师 3-初级工程师 */char ID_Wage10; /*员工的工资卡号 */char depart10; /*员工的部门*/int age; /*员工的年龄*/char sex; /*员工的性别*/char m_phone10; /*员工的手机*/char H_phone10; /*员工的住宅电话*/WAGE salary;WORK;WORK woN;int n;/*员工的总数*/void menu();/*员工管理操作主菜单函数声明*/void menu1();/*员工管理操作子菜单函数声明*
3、/*Author : GTCopyRight : function name : saveComments : 保存文件函数input : 无 output : 无CreatedDate : 2007/06/01*/save() /*保存函数,保存 n 个记录*/ int w=1;FILE *fp;int i;system( “cls“ ); if(fp=fopen(“work.txt“,“wb“)=NULL) /*以输出打开方式,在此前的记录被覆盖*/printf(“nCannot open filen“);return NULL;for(i=0;i9) /*判断员工编号是否为数字*/put
4、s(“Input error! Only be made up of (0-9).Please reinput!n“);w1=1;break;if(w1!=1)for(k=0;k800return tax;/*Author : GTCopyRight : function name : inputComments : 输入一条员工记录input : i: 表示第 i 个的员工信息output : 无CreatedDate : 2007/06/01*/void input(int i) /*输入一个记录函数*/int j,sum;no_input(i,i); /*调用员工编号输入函数*/prin
5、tf(“name:“);fflush(stdin);gets(woi.name);printf(“Bank ID:“);fflush(stdin);gets(woi.ID_Wage);printf(“grade“);scanf(“%d“, printf(“Department:“);fflush(stdin);gets(woi.depart);printf(“age:“);scanf(“%d“,printf(“sex:“);fflush(stdin);scanf(“%c“,printf(“mobile phone“);fflush(stdin);gets(woi.m_phone);printf
6、(“home phone“);fflush(stdin);gets(woi.H_phone);printf(“basic salary“);scanf(“%f“,woi.salary.tax=tax(woi.salary.wage1);printf(“Bonus:“);scanf(“%f“,printf(“water fee:“);scanf(“%f“,printf(“dian fee:“);scanf(“%f“,printf(“QingJie fee:“);scanf(“%f“,printf(“TV fee:“);scanf(“%f“,woi.salary.S_wage=woi.salary
7、.wage1+woi.salary.Bonus-woi.salary.tax-woi.salary.D_fee-woi.salary.Q_fee-woi.salary.S_fee-woi.salary.T_fee;/*Author : GTCopyRight : function name : enterComments : 输入员工管理系统信息记录input : 无output : 无CreatedDate : 2007/06/01*/void enter()/*输入模块*/int i;system( “cls“ ); printf(“How many record(0-%d)?:“,N);
8、scanf(“%d“, /*要输入的记录个数*/printf(“nEnter data nownn“);for(i=0;i=b_ages=woi;woi=wok;wok=s;printf(“The ordered data is:n“);browse();getch(); menu1();/*Author : GTCopyRight : function name : menu1Comments : 员工管理操作的子菜单input : 无output : 无CreatedDate : 2007/06/01*/void menu1()int n,w1;dosystem( “cls“ ); /*清
9、屏*/puts(“tttt 员工管理操作 !nn“);puts(“tt*MENU*nn“);puts(“tttt1.search by ID“);puts(“tttt2.search by age“);puts(“tttt3.count salary“);puts(“tttt4.order by salary“);puts(“tttt5.return to menu“);puts(“nntt*n“);printf(“Choice your number(1-5): bb“);scanf(“%d“,if(n5) /*对选择的数字作判断*/w1=1;printf(“your choice is n
10、ot between 1 and 4,Please input again:“);getchar();else w1=0; while(w1=1);/*选择功能*/switch(n)case 1:search_by_ID();break; /*输入模块*/case 2:search_by_age();break; /*浏览模块*/case 3:count_by_P();break; /*查找模块*/case 4:order();break; /*浏览模块*/case 5:menu();/*Author : GTCopyRight : function name : menuComments :
11、 员工管理系统主菜单input : 无output : 无CreatedDate : 2007/06/01*/void menu()int n,w1;dosystem( “cls“ ); /*清屏*/puts(“tttt 员工管理系统 !nn“);puts(“tt*MENU*nn“);puts(“tttt1.Enter new data“);puts(“tttt2.Browse all“);puts(“tttt3.opreration“);puts(“tttt4.Save file“);puts(“tttt5.Load file“);puts(“tttt6.Exit“);puts(“nntt*
12、n“);printf(“Choice your number(1-6): bb“);scanf(“%d“,if(n6) /*对选择的数字作判断*/w1=1;printf(“your choice is not between 1 and 7,Please input again:“);getchar();else w1=0; while(w1=1);/*选择功能*/switch(n)case 1:enter();break; /*输入模块*/case 2: browse();break; /*浏览模块*/case 3:menu1();break; /*子菜单模块*/case 4:save();break; /*保存模块*/case 5:n=load();break; /*加载模块*/case 6:exit(0);/*Author : GTCopyRight : function name : mainComments : 主函数input : 无output : 无CreatedDate : 2007/06/01*/main()menu();