




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、. . . . #include<string.h>#include<stdio.h>#define N 10000 /*员工的最大数*/typedef struct wagefloat wage1; /*员工的基本工资*/float Bonus; /*员工的奖金*/float tax; /*员工的税金*/float S_fee;
2、160; /*员工的水费*/float D_fee; /*员工的电费*/float T_fee; /*员工的有线电视费*/float Q_fee; /*员工的清洁费*/float S_wage; /*员工的实发工资*/WAGE;typedef struct worker char name10;
3、160; /*员工的*/char ID10; /*员工的工号*/ int ID_P; /*员工的职务代号 1-高级工程师 2-中级工程师 3-初级工程师 *
4、/char ID_Wage10; /*员工的工资卡号*/char depart10; /*员工的部门*/ int age; /*员工的年龄*/char sex; /*员工的性别*/char m_phone
5、10; /*员工的手机*/char H_phone10; /*员工的住宅*/ WAGE salary;WORK;WORK woN;int n;/*员工的总数*/void menu();/*员工管理操作主菜单函数声明*/void menu1();/*员工管理操作子菜单函数声明*/*Author : GTCopyRight : tgaosohu.
6、60; function name : save Comments : 保存文件函数input : 无 output
7、0; : 无CreatedDate : 2007/06/01*/save() /*保存函数,保存n个记录*/ int w=1;FILE *fp;int i;system( "cls&q
8、uot; ); if(fp=fopen("work.txt","wb")=NULL) /*以输出打开方式,在此前的记录被覆盖*/ printf("nCannot open filen"); return NULL; for(i=0;i<n;i+)if(fwrite(&woi,sizeof(struct worker),1,
9、fp)!=1) printf("file write errorn"); w=0;if(w=1) printf("file save ok!n");fclose(fp);getch(); menu();/*Author
10、0; : GTCopyRight : tgaosohu. function name : load Comments : 载入文件函数input : 无
11、0; output : 无CreatedDate : 2007/06/01*/load()
12、0; /*加载记录或可以计算记录个数的函数*/FILE *fp;int i,w;w=1;system( "cls" ); if(fp=fopen("work.txt","rb")=NULL) /*以输出打开方式,在此前的记录被覆盖*/ printf("nCannot open filen"); w=0; return NULL;
13、n=0;for(i=0;!feof(fp);i+) fread(&woi,sizeof(struct worker),1,fp); n+;n=n-1;fclose(fp);if(w=1) printf("Load file ok!");getch(); menu();return(i-1);
14、60; /*返回记录个数*/*Author : GTCopyRight : tgaosohu. function name : no_input Comments : 输入不能重复的员工编号inp
15、ut : i:表示第i个的员工编号信息 n:表示比较到第n个员工编号信息output : 无CreatedDate : 2007/06/01*/
16、void no_input(int i,int n) /*i表示第i个的员工编号信息,n表示比较到第n个员工编号*/int j,k,w1;do w1=0; printf("NO.:");
17、; scanf("%s",woi.ID); for(j=0;woi.IDj!='0'j+) /*员工编号输入函数,作了严格规定*/ if(woi.IDj<'0'|woi.IDj>'9') /*判断员工编号是否
18、为数字*/ puts("Input error! Only be made up of (0-9).Please reinput!n"); w1=1; break;
19、60; if(w1!=1) for(k=0;k<n;k+) /*比较到第n个员工编号*/
20、 /*排除第i个员工编号即你要修改的*/ if(k!=i&&am
21、p;strcmp(wok.IDj,woi.IDj)=0) /*判断员工编号是否有雷同*/ puts("This record is exist. please reinput!n");
22、; w1=1; break; while(w1=1);/*Author : GTCopyRight : tgaosohu. function name : tax Comments : 工资税金i
23、nput : s: 表示员工工资信息output : 员工的税金CreatedDate : 2007/06/01*/float tax(float s)float ta
24、x;if(s<=800) tax=0;else if(s>800&&s<=1400) tax=(s-800)*0.05; else if(s>1400) tax=(s-1400)*0.1+600*0.05; return tax;/*Author : GTCopyRight
25、; : tgaosohu. function name : input Comments : 输入一条员工记录input : i: 表示第i个的员工信息output
26、0; : 无CreatedDate : 2007/06/01*/void input(int i)
27、; /*输入一个记录函数*/ int j,sum; no_input(i,i); /*调用员工编号输入函数*/
28、; printf("name:");fflush(stdin);gets();printf("Bank ID:");fflush(stdin);gets(woi.ID_Wage);printf("grade");scanf("%d",&woi.ID_P); printf("Department:");fflush(stdin);gets(woi.depart); printf("age:&qu
29、ot;);scanf("%d",&woi.age); printf("sex:");fflush(stdin);scanf("%c",&woi.sex); printf("mobile phone");fflush(stdin);gets(woi.m_phone); printf("home phone"
30、;);fflush(stdin);gets(woi.H_phone);printf("basic salary");scanf("%f",&woi.salary.wage1);woi.salary.tax=tax(woi.salary.wage1);printf("Bonus:");scanf("%f",&woi.salary.Bonus);printf("water fee:");scanf("%f",&woi.salary.S_fee);print
31、f("dian fee:");scanf("%f",&woi.salary.D_fee);printf("QingJie fee:");scanf("%f",&woi.salary.Q_fee);printf("TV fee:");scanf("%f",&woi.salary.T_fee); woi.salary.S_wage=woi.salary.wage1+woi.salary.Bonus
32、-woi.salary.tax-woi.salary.D_fee-woi.salary.Q_fee-woi.salary.S_fee-woi.salary.T_fee;/*Author : GTCopyRight : tgaosohu. function name : enter Comments : 输入员工管理
33、系统信息记录input : 无output : 无CreatedDate : 2007/06/01*/void enter()/*输入模块*/int i;system( "
34、;cls" ); printf("How many record(0-%d)?:",N);scanf("%d",&n); /*要输入的记录个数*/printf("nEnter data nownn");for(i=0;i<n;i+)
35、; printf("nInput %dth record.n",i+1); input(i); /*调用输入函数*/ getch(); m
36、enu();/*Author : GTCopyRight : tgaosohu. function name : printf_one Comments : 输出一条员工信息记录input
37、0; : i:表示第i个的员工信息output : 无CreatedDate : 2007/06/01*/void printf_one(int i)
38、60; /*显示一个记录的函数*/int j;printf("%11s %-6s %-6s %d %d %c %6.2f %s
39、0; %s",woi.ID,,woi.ID_Wage,woi.ID_P,woi.age,woi.sex,woi.salary.S_wage,woi.m_phone,woi.H_phone);/*Author : GTCopyRight : tgaosohu. function name : printf_one_s
40、0; Comments : 输出一条员工工资记录input : i:表示第i个的工资信息output : 无CreatedDate :
41、 2007/06/01*/void printf_one_s(int i) /*显示一个记录的函数*/int j;printf(" %8.2f
42、160; %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f",woi.salary.wage1,woi.salary.S_wage,woi.salary.Bonus,woi.salary.D_fee,woi.salary.Q_fee,woi.salary.S_fee,woi.salary.T_fee,woi.salary.ta
43、x);/*Author : GTCopyRight : tgaosohu. function name : browse Comments : 输出员工管理系统信息记录input
44、60; : 无output : 无CreatedDate : 2007/06/01*/void browse()
45、0; /*浏览(全部)模块*/int i,j;system( "cls" ); puts("n-");printf("nt工号 银行卡号 职称 年龄 性别 实发工资 手机 住宅n");for(i=0;i<n;i+) if(i!=0)&&(i%1
46、0=0) /*目的是分屏显示*/ printf("nnPass any key to contiune . . .");
47、getch(); puts("nn"); printf_one(i); /*调用显示一个记录的函数*/ printf("n")
48、;puts("n-");printf("tThere are %d record.n",n);getch(); /*按任意健*/menu();/*Author
49、60; : GTCopyRight : tgaosohu. function name : search_by_ID Comments : 按工号查找所有员工信息记录input :
50、160; 无output : 输出查找员工编号CreatedDate : 2007/06/01*/int search_by_ID()
51、; /*查找模块*/int i,k;struct worker s;k=-1;system( "cls" ); printf("nnEnter the ID:");scanf("%s",s.ID); /*输入要到达的地方*/for(i=0;i<n;
52、i+) /*查找要修改的数据*/ if(strcmp(s.ID,woi.ID)=0) k=i;
53、 /*找到要修改的记录*/ printf("nt工号 银行卡号 职称 年龄 性别 实发工资 手机 住宅n"); &
54、#160; printf_one(k); printf("工资信息:n"); printf("nt基本工资 实发工资 奖金 电费 清洁费 &
55、#160; 水费 电视费 税金n"); printf_one_s(k); break;
56、 /*调用显示一个记录的函数*/ if(k=-1) printf("nnNO exist!"); getch();
57、; menu1(); return -1;else getch(); menu1(); return k;/*Author : GTCopyRight : tgaosoh
58、u. function name : search_by_age Comments : 按年龄查找所有员工信息记录input : 无output &
59、#160; : 输出查找员工编号CreatedDate : 2007/06/01*/int search_by_age() /*查找模块*/in
60、t i,k,t_age,b_age;struct worker s;k=-1;system( "cls" ); printf("nnEnter the top age:");scanf("%d",&t_age); printf("nnEnter the bottom age:");scanf("%d",
61、&b_age); printf("nt工号 银行卡号 职称 年龄 性别 实发工资 手机 住宅n"); for(i=0;i<n;i+)
62、60; /*查找要修改的数据*/ if(woi.age>=b_age&&woi.age<=t_age) k=i; /*找到要修改的记录*/
63、 printf_one(k); break; /*调用显示一个记录的函数*/ if(k=-1)&
64、#160; printf("nnNO exist!"); getch(); menu1(); return -1;else getch();
65、0; menu1(); return k;/*Author : GTCopyRight : tgaosohu. function name : search_by_P Comments
66、 : 按职称统计所有员工的工资信息input : 无output : 无CreatedDate : 2007/06/01*/void count_by_P()
67、; /*查找模块*/int i,k;float S_sal3=0,0,0,sal3=0,0,0,bon3=0,0,0,tax3=0,0,0; system( "cls" ); for(i=0;i<n;i+
68、) /*查找要修改的数据*/ if(woi.ID_P=1) S_sal0=S_sal0+woi.salary.S_wage; sal0=sal0+woi.salary.wage1;
69、; bon0=bon0+woi.salary.Bonus; tax0=tax0+woi.salary.tax; else if(woi.ID_P=2) S_sal1=S_sal1+woi.salary.S_wage; sal1=sal1+woi.salary.wage1;
70、 bon1=bon1+woi.salary.Bonus; tax1=tax1+woi.salary.tax; else if(woi.ID_P=3) S_sal2=S_sal2+woi.salary.S_wage; sal2=sal2+woi.salary.wage1; bon2=bon2+wo
71、i.salary.Bonus; tax2=tax2+woi.salary.tax; printf("n级别为高级工程师的工资统计为:n");printf("实发工资:%f,基本工资:%f,奖金:%f,税金:%fn",S_sal0,sal0,bon0,tax0);printf("n级别为中级工程师的工资统计为:n");printf("实发工资:%f,基本工资:%f,奖金:%f,税金:
72、%fn",S_sal1,sal1,bon1,tax1);printf("n级别为初级工程师的工资统计为:n");printf("实发工资:%f,基本工资:%f,奖金:%f,税金:%fn",S_sal2,sal2,bon2,tax2);printf("n公司所有人员的工资统计为:n");printf("实发工资:%f,基本工资:%f,奖金:%f,税金:%fn",S_sal2,sal2,bon2,tax2);getch(); menu1();/*Author
73、60; : GTCopyRight : tgaosohu. function name : order Comments : 按照实发工资的高低排序input :
74、; 无output : 无CreatedDate : 2007/06/01*/void order()
75、60; /*排序模块(按平均成绩)*/int i,j,k;struct worker s;system( "cls" ); for(i=0;i<n-1;i+) /*选择法排序*/ k=i; for(j=i+1;j<n;j+)
76、; if(woj.salary.S_wage>wok.salary.S_wage) k=j; s=woi; woi=wok; wok=s; printf("The ordered data is:n");browse();getch(); menu1();/*Author
77、160; : GTCopyRight : tgaosohu. function name : menu1 Comments : 员工管理操作的子菜单input :
78、; 无output : 无CreatedDate : 2007/06/01*/void menu1()int n,w1; do system( "
79、;cls" ); /*清屏*/ puts("tttt 员工管理操作!nn");
80、 puts("tt*MENU*nn"); puts("tttt1.search by ID"); puts("tttt2.search by age"); puts("tttt3.count salary&
81、quot;); puts("tttt4.order by salary"); puts("tttt5.return to menu"); puts("nntt*n");
82、 printf("Choice your number(1-5): bb"); scanf("%d",&n); if(n<0|n>5)
83、; /*对选择的数字作判断*/ w1=1;
84、160; printf("your choice is not between 1 and 4,Please input again:"); getchar();
85、0; else w1=0; while(w1=1);/*选择功能*/switch(n) case 1:search_by_ID();break; /*输入模块*/ case 2:search_by_age();break;
86、60; /*浏览模块*/ case 3:count_by_P();break; /*查找模块*/ case 4:order();break; /*浏览模块*/ case 5:menu(); /*Author
87、; : GTCopyRight : tgaosohu. function name : menu Comments : 员工管理系统主菜单input :
88、0; 无output : 无CreatedDate : 2007/06/01*/void menu()int n,w1; do system( "cls" );
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业连带担保借款合同模板
- 道路拓宽及改造工程合同
- 办公用房租赁合同英文范本
- 厨师服务合同样本
- 夫妻共同购房合同条款
- 女方净身出户离婚法律合同模板
- 跨境融资合同(一)
- 职业技术学院大学生创新创业项目合同
- 新能源汽车电机技术演进与产业链创新考核试卷
- 文化产业与体育赛事结合考核试卷
- 北师大版二年级数学下册导学案全册
- 小学六年级综合实践有趣的魔方世界课件
- (新版)国网网络安全攻防学习考试题库(含答案)
- 烟叶分级工新教材(高级篇)
- 如何做好葆婴事业四张纸
- 制造企业人事管理制度范本
- 社区卫生服务管理(第一章新)课件
- 公路沥青路面施工技术规范JTGF40-2004
- 全方位管理理念下肿瘤心脏病学课件
- 普通生物学普通生物学试题
- H.248协议正常呼叫流程解析
评论
0/150
提交评论