已阅读5页,还剩16页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C语言程序设计课程设计实习报告实 验 题 目 职工工资管理 1问题描述:添加模块:添加职工或工资的信息删除模块:能通过姓名或者工号删除职工信息修改模块:修改职工信息查询模块:能通过姓名或者工号查询职工信息显示模块:显示全部职工信息文件管理模块:负责源数据文件的管理,包括新建、读取和保存源数据2概要设计 职工工资管理添加模块删除模块修改模块查询模块显示模块文件管理模块按姓名按工号按姓名按工号新建记录数据文件读取记录数据文件保存记录数据文件在各模块处用指针函数来使用后面的保存记录数据文件进行保存。3详细设计 include # include # include /*宏定义*/# define N 100 /*假设工人个数是100*/# define HEADER1 -n # define HEADER2 | Number | Name | Psex | Age | Time | Ywage | Ykou | Pwage |n# define HEADER3 |-|-|-|-|-|-|-|-|n# define FORMAT |%-8d|%-8s|%-8s|%-7d|%-6d|%-7d|%-6d|%-7d|n# define DATA p-num ,p-name,p-sex,p-age,p-time,p-ywage,p-ykou,p-pwage# define END -n/*/typedef struct workint num; /*/char name10; char sex10;int age; /*/ int time; /*/int ywage; /*/int ykou; /*/int pwage; /*/WORK;/*/typedef struct pointer_infoWORK*pHead; /*/int count; /*/char fname10; /*/ int saveflag; /*/PI; /*/void Menu(); void Add(PI*);void Del(PI*);void Save(PI*pi);void Modify(PI*pi);void Qur(PI*pi);void Load(PI*pi);void New(PI*pi);void Disp(PI*);void Wrong();void printheader();void main()int sel;WORK *pwork;PI pi;pwork = (WORK*)malloc(N * sizeof(WORK);pi.pHead = pwork;pi.count = 0;pi.fname0 = 0;pi.saveflag = 0;/*显示主函数*/Menu();printf(Please input your choice 05:);do scanf(%d,&sel); if (sel = 0) /*if (pi.saveflag =1) if (strlen(pi.fname)Save(&pi);else New(&pi);Save(&pi); */break;switch(sel) case 1:Add(&pi);break; case 2:Del(&pi);break;case 3:Modify(&pi);break;case 4:Qur(&pi);break; case 5:Disp(&pi);break;default:Wrong();break; while(1);pwork = pi.pHead;free(pwork);void printheader() printf(HEADER1);printf(HEADER2);printf(HEADER3);void Menu()system(cls);printf( The Workers Grade Wage System n);printf(*Menu*n);printf( * 1 添加 *n);printf( * 2 删除 *n);printf( * 3 修改 *n);printf( * 4 查询 *n);printf( * 5 显示 *n);printf( * 0 退出 *n);printf (*n);void Wrong( )printf(n*Error :input has wrong ! press any key to continue*n); void Add(PI* pi ) int num;/char sex10;int nSex;int i,flag=0;WORK * pwork,*p;do pwork=pi-pHead+pi-count;p=pi-pHead;printf(please input the number:(press 0return menu);scanf(%d,&num);for(i=1;icount; i+)if(num=p-num)printf (the number you input has exist,please input another one!n);flag=1;break;p+;if(flag) flag=0;continue;if (num != 0)pwork-num = num;elseMenu();printf(please input your choice05:);break;printf(please input the name:);scanf(%s,pwork-name);printf(please input the sex(0 is woman,1 is man):);scanf( %d, &nSex );if( nSex = 0 )strcpy( pwork-sex,woman);elsestrcpy( pwork-sex,man);printf(please input the time:);scanf(%d, &pwork-time);printf(please input the age:);scanf(%d, &pwork-age);printf(please input the Ywage:);scanf(%d, &pwork-ywage);printf(please input the Ykou:);scanf(%d, &pwork-ykou);pwork-pwage = pwork-ywage-pwork-ykou;pi-count+;pi-saveflag=1;while(1);void Qur(PI * pi)int a,i,num;WORK *p;char name10;p=pi-pHead;Menu();printf(1-search by numbern);printf(2-search by namen);printf(3-returnn);printf(please input your choice:1,2?);scanf(%d,&a);if(a=3) return;if(a=1)printf(please input the number for search:);scanf(%d,&num);for(i=1;icount; i+) if(num=p-num)break;p+;if(ipi-count)printf(no record foundn);return;else printheader();printf(FORMAT,DATA);printf(END);else if(a=2)printf(please input name to search:);scanf(%s,name);for(i=1;icount;i+)if(strcmp(name,p-name) !=0) break;p+;if(ipi-count)printf(no record foundn);return;else printheader();printf(FORMAT,DATA);printf(END);printf(Please input your choice05:);void Modify(PI *pi)int num,i;WORK *p,*pwork;p = pi-pHead;Menu();Disp(pi);printf(please input the number of work to modify:);scanf(%d,&num);for (i = 1;i count;i+)if (num = p-num)break;p+;if (i pi-count)printf(no record foundn);return;elseprintf(please input the number:(enter 0return menu);scanf(%d,&num);if (num!=0)p-num =num;elseMenu();return;printf(please input the name:);scanf(%s,p-name);printf(please input the sex:);scanf(%s,p-sex);printf(please input the age:);scanf(%d,&p-age);printf(please input the time:);scanf(%d,&p-time);printf(please input the ywage:);scanf(%d,&p-ywage);printf(please input the ykou:);scanf(%d,&p-ykou);pwork-pwage = pwork-ywage-pwork-ykou;pi-saveflag = 1;/*删除职工记录*/void Del(PI * pi)int sel,i,num;char name10;WORK *p;/*指针函数*/p=pi-pHead;Menu();printf(1-delete by numbern);/*选择工号*/printf(2-delete by namen);/*选择姓名*/printf(any key other-returnn);/*按别的键就返回*/printf(please input your choice:1,2?n);scanf(%d,&sel);if(sel!=1&sel!=2)/*按别的键*/ return;if( sel = 1 )/*选择工号*/printf(Please input the number to delete:);scanf(%d,&num);for(i=1;icount;i+)/*按学号搜索*/ if(num=p-num)break;p+;if(ipi-count)printf(no record foundn);return;else if(i=pi-count) /*删除中间某个记录,只需要将count减1*/pi-count-;pi-saveflag=1;printf(record delete successfully!n);else /*删除某个记录,只要将其后的数据前移覆盖即可*/ memcpy(p,p+1,(pi-pHead + pi-count - p)*sizeof(WORK);pi-count-;pi-saveflag = 1;printf(record delete successfully!n);else if(sel = 2)/*选择姓名*/printf(please input name to delete:);scanf(%s,name);for(i=1;icount;i+) if(strcmp(name,p-name) != 0)break;p+;if(ipi-count)printf(no record foundn);return;else if(i=pi-count)/*删除中间某个记录,只需要将count减1*/pi-count-;pi-saveflag=1;printf(record delete successfully!n);else /*删除某个记录,只要将其后的数据前移覆盖即可*/ memcpy(p,p+1,(pi-pHead+pi-count-p)*sizeof(WORK) );pi-count-;pi-saveflag=1;printf(record delete successfully!n);printf(please input your choice05:);/*显示*/void Disp(PI * pi)int i;WORK *p = pi-pHead;if (pi-count=0)printf(no record foundn);printf(nplease input your choice05:);return;printheader();for(i=1;icount;i+)printf(FORMAT,DATA);printf(END);p+;void New(PI *pi)FILE * fp;char name10;char fname10 =.;printf(please input the date file name foe create:);scanf(%s,fname);strcat(fname,name);strcat(fname,.dat);fp=fopen(fname,wb);if(fp=NULL)printf(n=open file error!n);return;strcpy(pi-fname,fname);fclose(fp);void Load (PI *pi) FILE * fp;WORK * p=pi-pHead;char name 10;char fname 10= .;printf( please input the data file name for load:);scanf( %s,name);strcat(fname,name);fp=fopen(fname , rb);if(fp=NULL) printf(n=open file error!n);return;pi-count = 0;pi-saveflag = 0;while(feof(fp)!=0)if(fread(p,sizeof(WORK),1,fp)pi-count+;p+;strcpy(pi-fname,name);printf(load data file %s successfully!,name);fclose(fp);void Save(PI * pi)FILE * fp;int numwriten;if (!strlen(pi-fname)New(pi);fp=fopen(pi-fname, wb);if(fp=NULL) printf(n=open file error!n);fclose(fp);return ;if (pi-count) numwriten = f
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年湖南省低空经济发展集团有限公司招聘11人考前自测高频考点模拟试题附答案
- 2026年一级注册建筑师之建筑结构考试题库300道含答案(a卷)
- 2026年一级注册建筑师之建筑经济、施工与设计业务管理考试题库300道含答案(a卷)
- 2026年一级建造师之一建铁路工程实务考试题库300道含答案【轻巧夺冠】
- 2026年中级银行从业资格之中级公司信贷考试题库300道含答案【a卷】
- 2025湖北宜昌市不动产交易和登记中心招聘编外聘用人员17人备考题库附答案
- 2025海南三亚市纪委监委(市委巡察办)招聘下属事业单位工作人员3人(第1号)备考题库附答案
- 2026年一级注册建筑师之建筑物理与建筑设备考试题库300道及答案(必刷)
- 2026广东省选聘珠海市干部队伍储备人才20人备考题库附答案
- 路政安全工作总结讲解
- 私人家政合同协议书
- 2025年中职汽车(汽车发动机保养)试题及答案
- 中学生安全法制教育课件
- 医院导诊礼仪培训案例
- 工地劳务班组协议书
- 2026年河北工业职业技术大学单招职业技能测试题库及答案解析(夺冠)
- 2024年新发布政府会计准则制度实施问答及应用案例
- 2025台州玉环市国有企业招聘12人笔试考试参考题库及答案解析
- 城市居民委员会组织法(2025修订)解读课件
- 安全生产军令状
- DB33∕T 2320-2021 工业集聚区社区化管理和服务规范
评论
0/150
提交评论