职工工资管理系统设计--C语言课程设计_第1页
职工工资管理系统设计--C语言课程设计_第2页
职工工资管理系统设计--C语言课程设计_第3页
职工工资管理系统设计--C语言课程设计_第4页
职工工资管理系统设计--C语言课程设计_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

1、.C语言程序设计课程设计实习报告实 验 题 目 职工工资管理 1问题描述:添加模块:添加职工或工资的信息删除模块:能通过姓名或者工号删除职工信息修改模块:修改职工信息查询模块:能通过姓名或者工号查询职工信息显示模块:显示全部职工信息文件管理模块:负责源数据文件的管理,包括新建、读取和保存源数据2概要设计 职工工资管理添加模块删除模块修改模块查询模块显示模块文件管理模块按姓名按工号按姓名按工号新建记录数据文件读取记录数据文件保存记录数据文件在各模块处用指针函数来使用后面的保存记录数据文件进行保存。3详细设计 include <stdio.h># include <stdlib.

2、h># include <string.h>/*宏定义*/# 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|%-7

3、d|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_infoWOR

4、K*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(

5、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;swit

6、ch(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&

7、quot;);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"

8、;);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 '0'return menu)");scanf(&

9、quot;%d",&num);for(i=1;i< pi->count; 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(&qu

10、ot;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

11、:");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-

12、>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 i

13、nput 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;i<= pi->count; i+) if(num=p->num)break;p+;if(i>pi->count)printf("no record foundn");return;else prin

14、theader();printf(FORMAT,DATA);printf(END);else if(a=2)printf("please input name to search:");scanf("%s",name);for(i=1;i<=pi->count;i+)if(strcmp(name,p->name) !=0) break;p+;if(i>pi->count)printf("no record foundn");return;else printheader();printf(FORMAT,D

15、ATA);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 < pi->count;i+)if (num = p->num)break;p+;i

16、f (i > pi->count)printf("no record foundn");return;elseprintf("please input the number:(enter '0'return menu)");scanf("%d",&num);if (num!=0)p->num =num;elseMenu();return;printf("please input the name:");scanf("%s",p->name);pri

17、ntf("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",&

18、;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");/*选择工

19、号*/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:"

20、);scanf("%d",&num);for(i=1;i<=pi->count;i+)/*按学号搜索*/ if(num=p->num)break;p+;if(i>pi->count)printf("no record foundn");return;else if(i=pi->count) /*删除中间某个记录,只需要将count减1*/pi->count-;pi->saveflag=1;printf("record delete successfully!n");else /*

21、删除某个记录,只要将其后的数据前移覆盖即可*/ 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;i<=pi->count;i+) if

22、(strcmp(name,p->name) != 0)break;p+;if(i>pi->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->cou

23、nt-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:

24、");return;printheader();for(i=1;i<=pi->count;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")

25、;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( "

26、%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

温馨提示

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

评论

0/150

提交评论