最新C语言课程设计报告—人事管理系统.doc

上传人:1595****071 文档编号:34715600 上传时间:2022-08-18 格式:DOC 页数:103 大小:217KB
返回 下载 相关 举报
最新C语言课程设计报告—人事管理系统.doc_第1页
第1页 / 共103页
最新C语言课程设计报告—人事管理系统.doc_第2页
第2页 / 共103页
点击查看更多>>
资源描述

《最新C语言课程设计报告—人事管理系统.doc》由会员分享,可在线阅读,更多相关《最新C语言课程设计报告—人事管理系统.doc(103页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-dateC语言课程设计报告人事管理系统前言人事管理系统前言:现代计算机技术的发展为人们的学习、生活、工作提供了很大的帮助,各行各业都需要特定计算系统的运用,我们需要了解这些系统是怎么样为我们服务以及他们是怎样编辑出来的。我们需要学习C语言编程,根据课堂讲授内容,做相应的自主练习,消化课堂所讲解的内容;通过调试典型例题或习题积累调试C程序的经验;通过完成辅导教材中的编程题,逐渐

2、培养编程能力、用计算机解决实际问题的能力,能够按照要求编辑一些基本的程序,提高自己的思维能力。题目:某高校主要人员有:在职人员(行政人员、教师、一般员工)、退休人员及临时工。现在需要储存这些人员的人事档案信息,内容包括编号、姓名、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间、人员类别。其中,人员编号唯一,不能重复。(1) 添加删除功能:能根据学院人事的变动情况,添加删除记录。(2) 查询功能:能根据编号和姓名进行查询。(3) 编辑功能(高级):根据查询对相应的记录进行修改并记录。(4) 统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人数,高学历高职称人数),统计要

3、求同时显示被统计着的信息。(5) 排序功能:按照年龄、来院时间进行排序。(6) 保存功能:能对输入的数据进行相应的存储。主函数main()添加与删除功能查询功能编辑功能统计功能排序功能保存功能分析:我们编辑的程序要能够满足题目的要求,可以进行这么多的功能的计算!但是在开始我们运行使用程序的时候必须要知道我们要运用这些功能中的哪一个!这就要求我们可以 程序中任意选择我们所需要的功能!很显然我们要编辑存储人员的信息自然要运用到文件!而人员的信息必须要以结构体的形式来表示才能够方便我们提取信息!我们选择了要运行的功能分支之后!这些功能是以主函数以外的被调函数!当有需要时被调函数还可以调用其他的被吊函

4、数!例如我们题目中的统计和查询功能,就可以用这种方式来编辑程序!方便清楚!设计: 很显然主程序要用到SWICTH函数,这样可以选择要运行的那个功能的函数来执行,而其他的功能函数则不必运行!三、解题思路1、定义结构 struct staff char num10; char name20; char sex10; int age; char title20; char p_landscape30; char Qualifications30; int Service_time; char come_time30; char category30;staff100;2、主程序进入主菜单函数void

5、 main() menu();/*主菜单函数*/void menu()char w0;do system(cls); fflush(stdin); /*清除缓冲区输入*/ puts(*高校人事管理系统*nn);开始 puts(tttt1)增加人员信息n); puts(tttt2)删除人员信息 n); puts(tttt3)查询人员信息n); puts(tttt4)修改人员信息n);主菜单函数 puts(tttt5)统计人员信息n); puts(tttt6)对人员排序n); puts(tttt7)保存人员信息n);开始开始 puts(tttt8)浏览人员信息n);结束 puts(tttt9)退出

6、n);开始 printf(tttt请选择 bb);开始开始 w0=getchar();开始while(w09);开始结束根据x的值调用各功能模块函数显示一系列功能选项switch(w0-48)case 1:add();break;case 2:delete_data();break;case 3:search();break;case 4:modify();break;case 5:stastic();break;case 6:sort();break;case 7:save();break;case 8:browse();break;case 9:break;(1)查询功能int searc

7、h_data()/*查找单个数据函数*/int i,flag;char s30,w0;system(cls);/*清屏*/n=load(); do fflush(stdin); /*清除缓冲区输入*/ printf( 通过1)编号 2)姓名 bb); w0=getchar(); while(w02); if(w0=1)/*按编号查找*/ flag=0; puts(输入人员编号:); scanf(%s,s); for(i=0;in;i+) if(strcmp(s,staffi.num)=0) printf_face();printf_one(staffi); flag=1;break; else

8、 continue; if(flag=0)puts(该人员不存在!); else /*按姓名查找*/ flag=0; puts(输入人员姓名:); scanf(%s,s); for(i=0;in;i+) if(strcmp(s,staffi.name)=0) printf_face(); printf_one(staffi); flag=1;break; else continue; if(flag=0) puts(该人员不存在!); return i;void search()int k;char w1;loop: k=search_data(); do fflush(stdin); /*清

9、除缓冲区输入*/ printf(1)回主菜单 2)退出 3)继续查询 bb); w1=getchar();while(w13); if(w1=1)menu(); else if(w1=2)exit(0); else goto loop; YNN输入编号输入wo的值 1或2结束输入姓名wo=2?wo=1?Y数据查询开始保存信息结束输入信息开始(2)增加人员信息void add()char w0,w1;loop: system(cls); puts(请输入编号(如001):); scanf(%s,s.num); if(test(s.num)goto loop;/*编号重复*/ puts(请输入姓名

10、:); scanf(%s,s.name); puts(请输入性别(男,女):); scanf(%s,s.sex); puts(请输入年龄:); scanf(%d,&s.age); puts(请输入职务(教授 副教授 讲师 助教 学生 后勤人员):); scanf(%s,s.duty); puts(请输入职称 (无 初级 高级 ):); scanf(%s,s.title); puts(请输入政治面貌( 党员 非党员 ):); scanf(%s,s.p_landscape); puts(请输入最高学历(小学 初中 高中 大学 硕士学位 更高):); scanf(%s,s.Qualification

11、s); puts(请输入任职时间:); scanf(%d,&s.Service_time); puts(请输入来院时间(如20050101):); scanf(%s,e_time); puts(请输入人员类别(行政人员 教师 一般员工 退休人员 临时工):); scanf(%s,s.category); do fflush(stdin); /*清除缓冲区输入*/ printf(是否保存?1)是 2)否 bb); w0=getchar();while(w02); switch(w0) case 1:save(s);break; case 2:break; do fflush(stdin); /*

12、清除缓冲区输入*/ printf(1)继续增加人员信息 2)回主菜单 3)退出 bb); w1=getchar();while(w13); if(w1=1)goto loop; else if(w1=2)menu(); else exit(0);(3)保存信息void save() char w0;save_all(); printf(所有信息已保存!n); dofflush(stdin); /*清除缓冲区输入*/printf(1) 回主菜单 2) 退出 bb);w0=getchar();while(w02);if(w0=1)menu(); else exit(0);void save_all

13、()/*保存所有数据函数*/int i; FILE *fp; if(fp=fopen(text.txt,wb)=NULL)printf(无法打开文件!);exit(0);for(i=0;in;i+)if(staffi.age!=0)fprintf(fp,%s %s %s %d %s %s %s %s %d %s %sn,staffi.num,staffi.name,staffi.sex,staffi.age,staffi.duty,staffi.title,staffi.p_landscape,staffi.Qualifications,staffi.Service_time,e_time,s

14、taffi.category); else continue;fclose(fp);(4)删除人员void delete_data()int k; char w0,w1; loop: k=search_data(); if(kn) do fflush(stdin); /*清除缓冲区输入*/ printf(确认要删除该人员信息? 1)是 2)否 bb); w0=getchar();while(w02); if(w0=1) staffk.age=0; save_all();puts(该人员信息已被删除!); do fflush(stdin); /*清除缓冲区输入*/删除信息结束查询要删除的信息开始

15、 printf(1)继续删除数据 2)回主菜单 3)退出 bb); w1=getchar();while(w13); if(w1=1) goto loop; else if(w1=2)menu(); else exit(0); (5)修改人员信息void modify()int k=0,w0,g;char h30,w1,w2;loop: g=search_data(); if(gn) do puts(ttt修改: 1)编号); puts(ttt 2)姓名); puts(ttt 3)性别); puts(ttt 4)年龄); puts(ttt 5)职务); puts(ttt 6)职称); puts

16、(ttt 7)政治面貌); puts(ttt 8)最高学历); puts(ttt 9)任职时间); puts(ttt 10)来院时间);修改人员信息查询要修改信息的人员开始 puts(ttt 11)人员类别); printf( 请选择 : bb); scanf(%d,&w0);while(w011); switch(w0) case 1:puts(请输入新编号:); scanf(%s,h);strcpy(staffg.num,h);break; case 2:puts(请输入姓名:); scanf(%s,h);strcpy(staffg.name,h);break; case 3:puts(请

17、输入性别:); scanf(%s,h);strcpy(staffg.sex,h);break; case 4:puts(请输入年龄:);保存信息 scanf(%d,&k);staffg.age=k;break; case 5:puts(请输入职务:); scanf(%s,h);strcpy(staffg.duty,h);break; case 6:puts(请输入职称:);结束 scanf(%s,h);strcpy(staffg.title,h);break; case 7:puts(请输入政治面貌:); scanf(%s,h);strcpy(staffg.p_landscape,h);bre

18、ak; case 8:puts(请输入最高学历:); scanf(%s,h);strcpy(staffg.Qualifications,h);break; case 9:puts(请输入任职时间:); scanf(%d,&k);staffg.Service_time=k;break; case 10:puts(请输入来院时间:); scanf(%s,h);strcpy(e_time,h);break; case 11:puts(请输入人员类别:); scanf(%s,h);strcpy(staffg.category,h);break; do fflush(stdin); /*清除缓冲区输入*

19、/ printf(是否保存?1)保存 2)否 bb); w1=getchar();while(w12); if(w1=1)save_all(); puts(保存修改成功!); do fflush(stdin); /*清除缓冲区输入*/ printf(1)继续修改 2)回主菜单 3)退出 bb); w2=getchar();while(w23); if(w2=1)goto loop; else if(w2=2)menu(); else exit(0); (6)统计人员信息void stastic()int i,count;char w0,w1;n=load();if(n=0)puts(没有数据!

20、);getchar();menu();loop: system(cls);dofflush(stdin); /*清除缓冲区输入*/printf(通过1)在职人员 2)党员n);printf( 3)女工人数 4)最高学历 bb);w0=getchar();while(w04);if(w0=1)/*统计在职人员*/printf_face();for(i=0,count=0;in&staffi.age;i+)if(strcmp(staffi.category,退休人员)!=0&strcmp(staffi.category,临时工)!=0)count+; printf_one(staffi);prin

21、tf(tttt共有%d条记录,count);else if(w0=2)/*统计党员*/printf_face();for(i=0,count=0;in;i+)统计人数结束选择按照何种方式开始if(strcmp(staffi.p_landscape,党员)=0)count+; printf_one(staffi);printf(tttt共有%d条记录,count);else if(w0=3)/*统计女工人员*/printf_face();for(i=0,count=0;in;i+)if(strcmp(staffi.sex,女)=0)count+; printf_one(staffi);print

22、f(tttt共有%d条记录,count);else /*统计高学历人员*/printf_face();for(i=0,count=0;in;i+)if(strcmp(staffi.Qualifications,硕士学位)=0|strcmp(staffi.Qualifications,更高)=0)count+; printf_one(staffi);printf(tttt共有%d条记录,count);dofflush(stdin); /*清除缓冲区输入*/printf(n1)继续统计 2)回主菜单 3)退出 bb);w1=getchar();while(w13);if(w1=1) goto lo

23、op;else if(w1=2)menu();else exit(0);排序结束选择按照什么排序开始(7) 排序功能void sort()int i,j;char w0,w1;struct staff s1;loop: n=load(); system(cls); do fflush(stdin); /*清除缓冲区输入*/ printf(通过 1)年龄 2)来院时间 bb); w0=getchar();while(w02); if(w0=1)/*按年龄排序*/ for(i=0;in-1;i+)/*选择法排序*/ for(j=i+1;jstaffj.age) s1=staffi;staffi=s

24、taffj;staffj=s1; else /*按来院时间排序*/ for(i=0;in-1;i+)/*选择法排序*/ for(j=i+1;j0) s1=staffi;staffi=staffj;staffj=s1; printf_face(); for(i=0;in;i+) /*显示排序结果*/ printf_one(staffi); do fflush(stdin); /*清除缓冲区输入*/ printf(n1)回主菜单 2)继续排序 3)退出 bb); w1=getchar();while(w13); if(w1=1) menu(); else if(w1=2)goto loop; el

25、se exit(0);四、运行与测试报告*高校人事管理系统* 1)增加人员信息 2)删除人员信息 3)查询人员信息 4)修改人员信息 5)统计人员信息 6)对人员排序 7)保存人员信息 8)浏览人员信息 9)退出 请选择 【 1】请输入编号(如001):20071003335请输入姓名:majianbo请输入性别(男,女):nan请输入年龄:20请输入职务(教授 副教授 讲师 助教 学生 后勤人员):jiaoshou请输入职称 (无 初级 高级 ):gaoji请输入政治面貌( 党员 非党员 ):danyuan请输入最高学历(小学 初中 高中 大学 硕士学位 更高):shuoshi请输入任职时间

26、:20070901请输入来院时间(如20050101):20070901请输入人员类别(行政人员 教师 一般员工 退休人员 临时工):jiaoshi是否保存?1)是 2)否 1该信息已成功保存!1)继续增加人员信息 2)回主菜单 3)退出 程序:#include#include #include struct staff/*定义结构体*/ char num10;/*编号*/ char name20;/*姓名*/ char sex10;/*性别*/ int age;/*年龄*/ char duty20;/*职务*/ char title20;/*职称*/ char p_landscape30;/

27、*政治面貌*/ char Qualifications30;/*学历*/ int Service_time;/*任职时间*/ char come_time30;/*来院时间*/ char category30;/*人员类别*/staff100;struct staff s;int n;void menu();void printf_face()/*显示数据结构项目函数*/ printf(编号姓名 性别年龄职务 职称 政治面貌学历 任职时间来院时间 人员类别n); void printf_one(struct staff p)/*输出单个数据函数*/printf(%-4s%-7s%-5s%-3d

28、%-7s%-5s%-8s%-12s%-5d%-12s%-3sn,p.num,p.name,p.sex,p.age,p.duty,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_time,p.category);int load()/*加载函数*/int i=0;FILE *fp;if(fp=fopen(text.txt,rb)=NULL)return 0; exit(0); for(i=0;!feof(fp);i+) /*输出数据到结构体*/ fscanf(fp,%s %s %s %d %s %s %s %s %d %s %sn,

29、staffi.num,staffi.name,staffi.sex,&staffi.age,staffi.duty,staffi.title,staffi.p_landscape,staffi.Qualifications,&staffi.Service_time,e_time,staffi.category); fclose(fp); return i;int search_data()/*查找单个数据函数*/int i,flag;char s30,w0;system(cls);/*清屏*/n=load(); do fflush(stdin); /*清除缓冲区输入*/ printf( 通过1

30、)编号 2)姓名 bb); w0=getchar(); while(w02); if(w0=1)/*按编号查找*/ flag=0; puts(输入人员编号:); scanf(%s,s); for(i=0;in;i+) if(strcmp(s,staffi.num)=0) printf_face();printf_one(staffi); flag=1;break; else continue; if(flag=0)puts(该人员不存在!); else /*按姓名查找*/ flag=0; puts(输入人员姓名:); scanf(%s,s); for(i=0;in;i+) if(strcmp(

31、s,staffi.name)=0) printf_face(); printf_one(staffi); flag=1;break; else continue; if(flag=0) puts(该人员不存在!); return i;void save_all()/*保存所有数据函数*/int i; FILE *fp; if(fp=fopen(text.txt,wb)=NULL)printf(无法打开文件!);exit(0);for(i=0;in;i+)if(staffi.age!=0)fprintf(fp,%s %s %s %d %s %s %s %s %d %s %sn,staffi.nu

32、m,staffi.name,staffi.sex,staffi.age,staffi.duty,staffi.title,staffi.p_landscape,staffi.Qualifications,staffi.Service_time,e_time,staffi.category); else continue;fclose(fp);int test(char h10)/*检查编号是否重复*/int i;n=load();for(i=0;in;i+)if(strcmp(h,staffi.num)=0)puts(输入的编号有重复!请重新输入编号!);system(pause);retur

33、n 1;return 0;void single_save(struct staff p)/*保存单个数据函数*/FILE *fp; if(fp=fopen(text.txt,ab+)=NULL) printf(无法打开文件!);exit(0); fprintf(fp,%s %s %s %d %s %s %s %s %d %s %sn,p.num,p.name,p.sex,p.age,p.duty,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_time,p.category); printf(该信息已成功保存!n);fclose(fp);/*修改模块*/void modify()int k=0,w0,g;char h30,w1,w2;loop: g=search_data(); if(gn) do puts(ttt修改: 1)编号); puts(ttt 2)姓名); puts(ttt 3)性别); puts(ttt 4)年龄); puts(ttt 5)职务); puts(ttt 6)职称); puts(ttt 7)政治面貌); puts(ttt 8)最高学历); puts(ttt 9)任职时间); puts(ttt 10)来院时间); puts(ttt 11)人员类别); printf( 请

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 成人自考

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com