C语言课程设计——职工工资管理.doc_第1页
C语言课程设计——职工工资管理.doc_第2页
C语言课程设计——职工工资管理.doc_第3页
C语言课程设计——职工工资管理.doc_第4页
C语言课程设计——职工工资管理.doc_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

c语言课程设计报告书题目:职工工资管理学号:0911080008姓名:李志学号:0911060010姓名:刘凯学号:0904080001姓名:张琛 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;pwork = pi-phead;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 sa

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论