




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河南省豫西南部分示范性高中2026届高一化学第一学期期末教学质量检测试题含解析
- 期货行业面试实战模拟题库:投资策略与风险管理篇
- 2026届湖南明德中学化学高一上期末预测试题含解析
- 高潜力职业规划:建造师面试题库主题文档
- 10月10日世界精神卫生日主题教育课件
- 胸腔骨骼结构详解
- 新概念频率副词全英讲解
- 物理治疗学三体位转移技术
- 填词岗位面试实战模拟题
- 八年级生物上册总复习课件
- 2025上海市八年级升九年级数学暑假提升讲义:相似三角形压轴题(六大题型)原卷版
- 2025年工业互联网工程技术人员考核试题题库及答案
- 供货组织方案范文
- 农行OCRM系统讲解
- 2025年《药品经营和使用质量监督管理办法》培训试题及答案
- 2024年云南省县乡教师选调考试《教育学》真题汇编带解析(原创题)
- 工贸安全员考试题库及答案大全
- 羊肚菌栽培及其管理课件
- 2025全国农业(水产)行业职业技能大赛(水生物病害防治员)选拔赛试题库(含答案)
- 网约车停运损失赔偿协议书范文
- 产前筛查规范化流程和质量控制侯巧芳 课件
评论
0/150
提交评论