您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 薪酬管理 > c语言课程设计 职工信息管理系统设计
1仲恺农业工程学院课程设计报告课程名称:C语言程序设计院(系):专业:班级:学号:姓名:指导老师:2目录题目··························································3一.需求和规格说明············································3二.算法设计··················································3三.详细设计··················································4四.调试分析·················································141.调试结果··················································142.调试数据··················································152.1调试建立文件并输入职工信息·······························152.2调试添加职工信息·········································152.3调试查询职工信息·········································162.3.1调试按学历查询·········································162.3.2调试按工资查询·········································162.4调试修改职工信息·········································172.5调试删除职工信息·········································172.6调试输出职工信息·········································18五.总结····················································18参考文献····················································193题目:职工信息管理系统设计一、需求和规格说明:问题描述,即题目要解决的问题是什么对企业而言,人力资源是企业最宝贵的资源,也是企业的“生命线”。随着当今企业人员数量的不断增加、分工的不断细化、各行业间联系的不断密切,对职工信息管理的要求也不断提高,实现职工管理自动化也无疑将带来高效率的企业管理。最初的职工信息管理采用人工方式,记录量大、易出错,越来越不适应实际管理工作地需要。职工信息管理系统就是用电脑代替大量的人工记录,完成更多的信息处理,具有方便、准确度高且可以长期保存的特点。职工信息管理系统主要用于高效地收集和管理职工的相关信息,便于以后的查找及应用,本系统可以提供对职工信息的查询、添加、修改、删除等功能。二、算法设计(程序流程图)图1文件流程图k=1k=2default文件输入职工信息输出职工信息输入k按学历查询请按1按工资查询请按2退出查询breakbreakbreak4图2查询流程图m=1m=2m=3m=4m=5m=0图3菜单流程图三、详细设计(程序)#includestdio.h#includestdlib.h#includestring.hstructstaff{charname[8];charnum[10];charsex[10];charage[10];输入m添加职工信息请按1查询职工信息请按2breakbreak修改职工信息请按3删除职工信息请按4输出职工信息请按5breakbreakbreak退出系统请按05charrecord[10];charposition[15];charwages[10];chartel[15];charaddr[50];}worker;/*定义一个结构体*/charfilename[20];/*文件名*/FILE*fp;voidcreat();/*定义一个创建函数*/voidoutput();/*定义一个输出信息的函*/voidsearch();/*定义一个查询的函数*/voidsearch1();/*定义一个按学历查询数*/voidsearch2();/*定义一个按工资查询数*/voidappend();/*定义一个添加函数*/voidmodify();/*定义一个修改函数*/voiddeleted();/*定义一个删除函数*/voidmain()/*主函数*/{intm;creat();while(1){printf(=====职工信息管理系统=====\n);printf(---------------------------------\n);printf(\n添加职工信息,请按1);printf(\n查询职工信息,请按2);printf(\n修改职工信息,请按3);printf(\n删除职工信息,请按4);printf(\n输出职工信息,请按5);printf(\n退出系统,请按0\n);/*输出提示信*/6printf(---------------------------------\n);printf(请您在上述功能中选择(0——5):);scanf(%d,&m);if(m=0&&m=5){switch(m){case1:append();break;case2:search();break;case3:modify();break;case4:deleted();break;case5:output();break;case0:exit(1);}printf(\n\n操作完毕,请再次选择!);}elseprintf(\n\n选择错误,请再次选择!);}}voidcreat(){structstaffone;printf(\n请输入文件名:);scanf(%s,filename);/*创建一个文件的名字*/if((fp=fopen(filename,w))==NULL)/*打开文件,实现向文件数*/{printf(\n不能建立!);exit(1);}7fprintf(fp,%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,姓名,工号,性别,年龄,学历,职位,工资,电话号码,住址);printf(\n请输入职工信息(以0结束)\n);printf(姓名:\n);scanf(%s,one.name);while(strcmp(one.name,0)){printf(工号:\n);scanf(%s,one.num);printf(性别:\n);scanf(%s,one.sex);printf(年龄:\n);scanf(%s,one.age);printf(学历:\n);scanf(%s,one.record);printf(职位:\n);scanf(%s,one.position);printf(工资:\n);scanf(%s,one.wages);printf(电话:\n);scanf(%s,one.tel);printf(住址:\n);scanf(%s,one.addr);/*输出职工的相关信*/fprintf(fp,%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wages,one.tel,one.addr);scanf(%s,one.name);}fclose(fp);/*关闭文件*/}voidoutput()/*输出函数*/8{structstaffone;if((fp=fopen(filename,r))==NULL)/*打开文件*/{printf(\n不能打开该文件!);exit(1);}printf(\n\n%20s\n,职工信息管理系统);/*向文件输入数据*/while(!feof(fp)){fscanf(fp,%s%s%s%s%s%s%s%s%s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wages,one.tel,one.addr);printf(%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wages,one.tel,one.addr);}fclose(fp);/*关闭文件*/}voidappend()/*添加函数*/{structstaffone;if((fp=fopen(filename,a))==NULL)/*打开文件*/{printf(\n不能打开该文件!);exit(1);}printf(\n请输入添加职工信息(姓名、工号、性别、年龄、学历、职位、工资、电话、地址)\n);/*向文件中输入数据*/scanf(%s%s%s%s%s%s%s%s%s,one.name,one.num,one.sex,one.age,one.record,one.position,one.wages,one.tel,one.addr);fprintf(fp,%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,9one.sex,one.age,one.record,one.position,one.wages,one.tel,one.addr);fclose(fp);/*关闭文件*/}voidsearch()/*查询函数*/{intk;printf(按学历查询,请按1\n);printf(按工资查询,请按2\n);scanf(%d,&k);switch(k){case1:search1();break;case2:search2();break;default:printf(退出查询!);break;}}voidsearch1(){intk=0,t;charrecord[8];structstaffone;printf(\n请输入您要查找的学历:);scanf(%s,record);if((fp=fopen(filename,rb))==NULL)/*打开文件*/{printf(\n不能打开文件!);exit(1);}while(!feof(fp)){10fscanf(fp,%s%s%s%s%s%s%s%s%s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wages,one.tel,one.addr);if(!strcmp(record,one.record)){printf(\n\n已查到,记录为:);printf(\n%-10s%-8s%-5s%-5s%-10s%-8s%-8s%-10s%-15s\n,one.name,one.num,one.sex,one.age,one.record,one.position,one.wages,one.tel,one.addr);k=1;}}if(!k)printf(\n\n对不起,查无此人!。);fclose(fp);printf(\n\n继续请输入1);printf(\n\n返回请输入0);scanf(%d,&t);switch(t){case1:search1();break;case0:break;default:break;}}voidsearch2(){intk=0,t;charwages[8];structstaffone;pr
本文标题:c语言课程设计 职工信息管理系统设计
链接地址:https://www.777doc.com/doc-3422195 .html