C语言课程设计报告—人事管理系统(共21页)_第1页
C语言课程设计报告—人事管理系统(共21页)_第2页
C语言课程设计报告—人事管理系统(共21页)_第3页
C语言课程设计报告—人事管理系统(共21页)_第4页
C语言课程设计报告—人事管理系统(共21页)_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

1、精选优质文档-倾情为你奉上人事管理系统前言:现代计算机技术的发展为人们的学习、生活、工作提供了很大的帮助,各行各业都需要特定计算系统的运用,我们需要了解这些系统是怎么样为我们服务以及他们是怎样编辑出来的。我们需要学习C语言编程,根据课堂讲授内容,做相应的自主练习,消化课堂所讲解的内容;通过调试典型例题或习题积累调试C程序的经验;通过完成辅导教材中的编程题,逐渐培养编程能力、用计算机解决实际问题的能力,能够按照要求编辑一些基本的程序,提高自己的思维能力。题目:某高校主要人员有:在职人员(行政人员、教师、一般员工)、退休人员及临时工。现在需要储存这些人员的人事档案信息,内容包括编号、姓名、年龄、职

2、务、职称、政治面貌、最高学历、任职时间、来院时间、人员类别。其中,人员编号唯一,不能重复。(1) 添加删除功能:能根据学院人事的变动情况,添加删除记录。(2) 查询功能:能根据编号和姓名进行查询。(3) 编辑功能(高级):根据查询对相应的记录进行修改并记录。(4) 统计功能:能根据多种参数进行人员的统计(在职人数、党员人数、女工人数,高学历高职称人数),统计要求同时显示被统计着的信息。(5) 排序功能:按照年龄、来院时间进行排序。(6) 保存功能:能对输入的数据进行相应的存储。主函数main()添加与删除功能查询功能编辑功能统计功能排序功能保存功能分析:我们编辑的程序要能够满足题目的要求,可以

3、进行这么多的功能的计算!但是在开始我们运行使用程序的时候必须要知道我们要运用这些功能中的哪一个!这就要求我们可以 程序中任意选择我们所需要的功能!很显然我们要编辑存储人员的信息自然要运用到文件!而人员的信息必须要以结构体的形式来表示才能够方便我们提取信息!我们选择了要运行的功能分支之后!这些功能是以主函数以外的被调函数!当有需要时被调函数还可以调用其他的被吊函数!例如我们题目中的统计和查询功能,就可以用这种方式来编辑程序!方便清楚!设计: 很显然主程序要用到SWICTH函数,这样可以选择要运行的那个功能的函数来执行,而其他的功能函数则不必运行!三、解题思路1、定义结构 struct staff

4、 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 main() menu();/*主菜单函数*/void menu()char w0;do system("cls"); fflush(stdin); /*清除缓冲区输入*/ puts("*高校人事管理系统*

5、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("t

6、ttt9)退出n");开始 printf("tttt请选择 bb");开始开始 w0=getchar();开始while(w0<'1'|w0>'9');开始结束根据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();

7、break;case 8:browse();break;case 9:break;(1)查询功能int search_data()/*查找单个数据函数*/int i,flag;char s30,w0;system("cls");/*清屏*/n=load(); do fflush(stdin); /*清除缓冲区输入*/ printf(" 通过1)编号 2)姓名 bb"); w0=getchar(); while(w0<'1'|w0>'2'); if(w0='1')/*按编号查找*/ flag=0;

8、 puts("输入人员编号:"); scanf("%s",s); for(i=0;i<n;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;i<n;i+) if(strc

9、mp(s,)=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); /*清除缓冲区输入*/ printf("1)回主菜单 2)退出 3)继续查询 bb"); w1=getchar();while(w1<'1'|w1>&#

10、39;3'); 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(&q

11、uot;请输入姓名:"); scanf("%s",); puts("请输入性别(男,女):"); scanf("%s",s.sex); puts("请输入年龄:"); scanf("%d",&s.age); puts("请输入职务(教授 副教授 讲师 助教 学生 后勤人员):"); scanf("%s",s.duty); puts("请输入职称 (无 初级 高级 ):"); scanf("%s&q

12、uot;,s.title); puts("请输入政治面貌( 党员 非党员 ):"); scanf("%s",s.p_landscape); puts("请输入最高学历(小学 初中 高中 大学 硕士学位 更高):"); scanf("%s",s.Qualifications); puts("请输入任职时间:"); scanf("%d",&s.Service_time); puts("请输入来院时间(如):"); scanf("%s"

13、;,e_time); puts("请输入人员类别(行政人员 教师 一般员工 退休人员 临时工):"); scanf("%s",s.category); do fflush(stdin); /*清除缓冲区输入*/ printf("是否保存?1)是 2)否 bb"); w0=getchar();while(w0<'1'|w0>'2'); switch(w0) case 1:save(s);break; case 2:break; do fflush(stdin); /*清除缓冲区输入*/ pri

14、ntf("1)继续增加人员信息 2)回主菜单 3)退出 bb"); w1=getchar();while(w1<'1'|w1>'3'); 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) 退出 b

15、b");w0=getchar();while(w0<'1'|w0>'2');if(w0='1')menu(); else exit(0);void save_all()/*保存所有数据函数*/int i; FILE *fp; if(fp=fopen("text.txt","wb")=NULL)printf("无法打开文件!");exit(0);for(i=0;i<n;i+)if(staffi.age!=0)fprintf(fp,"%s %s %s %

16、d %s %s %s %s %d %s %sn",staffi.num,,staffi.sex,staffi.age,staffi.duty,staffi.title,staffi.p_landscape,staffi.Qualifications,staffi.Service_time,e_time,staffi.category); else continue;fclose(fp);(4)删除人员void delete_data()int k; char w0,w1; loop: k=search_data(); if(k<n) d

17、o fflush(stdin); /*清除缓冲区输入*/ printf("确认要删除该人员信息? 1)是 2)否 bb"); w0=getchar();while(w0<'1'|w0>'2'); if(w0='1') staffk.age=0; save_all();puts("该人员信息已被删除!"); do fflush(stdin); /*清除缓冲区输入*/删除信息结束查询要删除的信息开始 printf("1)继续删除数据 2)回主菜单 3)退出 bb"); w1=ge

18、tchar();while(w1<'1'|w1>'3'); 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(g<n) do puts("ttt修改: 1)编号"); puts("ttt 2)姓名"); puts("ttt 3)性别");

19、 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(" 请选择 : bb"); scanf("%d

20、",&w0);while(w0<1|w0>11); switch(w0) case 1:puts("请输入新编号:"); scanf("%s",h);strcpy(staffg.num,h);break; case 2:puts("请输入姓名:"); scanf("%s",h);strcpy(,h);break; case 3:puts("请输入性别:"); scanf("%s",h);strcpy(staffg.sex,h

21、);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("请输入政治面貌:&quo

22、t;); scanf("%s",h);strcpy(staffg.p_landscape,h);break; 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(&q

23、uot;%s",h);strcpy(e_time,h);break; case 11:puts("请输入人员类别:"); scanf("%s",h);strcpy(staffg.category,h);break; do fflush(stdin); /*清除缓冲区输入*/ printf("是否保存?1)保存 2)否 bb"); w1=getchar();while(w1<'1'|w1>'2'); if(w1='1')save_all(); pu

24、ts("保存修改成功!"); do fflush(stdin); /*清除缓冲区输入*/ printf("1)继续修改 2)回主菜单 3)退出 bb"); w2=getchar();while(w2<'1'|w2>'3'); 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(&quo

25、t;没有数据!");getchar();menu();loop: system("cls");dofflush(stdin); /*清除缓冲区输入*/printf("通过1)在职人员 2)党员n");printf(" 3)女工人数 4)最高学历 bb");w0=getchar();while(w0<'1'|w0>'4');if(w0='1')/*统计在职人员*/printf_face();for(i=0,count=0;i<n&&staffi.

26、age;i+)if(strcmp(staffi.category,"退休人员")!=0&&strcmp(staffi.category,"临时工")!=0)count+; printf_one(staffi);printf("tttt共有%d条记录",count);else if(w0='2')/*统计党员*/printf_face();for(i=0,count=0;i<n;i+)统计人数结束选择按照何种方式开始if(strcmp(staffi.p_landscape,"党员"

27、;)=0)count+; printf_one(staffi);printf("tttt共有%d条记录",count);else if(w0='3')/*统计女工人员*/printf_face();for(i=0,count=0;i<n;i+)if(strcmp(staffi.sex,"女")=0)count+; printf_one(staffi);printf("tttt共有%d条记录",count);else /*统计高学历人员*/printf_face();for(i=0,count=0;i<n;i

28、+)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(w1<'1'|w1>'3');if(w1=&

29、#39;1') goto loop;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(w0<'1'|w0>'2');

30、if(w0='1')/*按年龄排序*/ for(i=0;i<n-1;i+)/*选择法排序*/ for(j=i+1;j<n;j+) if(staffi.age>staffj.age) s1=staffi;staffi=staffj;staffj=s1; else /*按来院时间排序*/ for(i=0;i<n-1;i+)/*选择法排序*/ for(j=i+1;j<n;j+) if(strcmp(e_time,e_time)>0) s1=staffi;staffi=staffj;staffj=s1; pri

31、ntf_face(); for(i=0;i<n;i+) /*显示排序结果*/ printf_one(staffi); do fflush(stdin); /*清除缓冲区输入*/ printf("n1)回主菜单 2)继续排序 3)退出 bb"); w1=getchar();while(w1<'1'|w1>'3'); if(w1='1') menu(); else if(w1='2')goto loop; else exit(0);四、运行与测试报告*高校人事管理系统* 1)增加人员信息 2)删除

32、人员信息 3)查询人员信息 4)修改人员信息 5)统计人员信息 6)对人员排序 7)保存人员信息 8)浏览人员信息 9)退出 请选择 【 1】请输入编号(如001):请输入姓名:majianbo请输入性别(男,女):nan请输入年龄:20请输入职务(教授 副教授 讲师 助教 学生 后勤人员):jiaoshou请输入职称 (无 初级 高级 ):gaoji请输入政治面貌( 党员 非党员 ):danyuan请输入最高学历(小学 初中 高中 大学 硕士学位 更高):shuoshi请输入任职时间:请输入来院时间(如):请输入人员类别(行政人员 教师 一般员工 退休人员 临时工):jiaoshi是否保存?

33、1)是 2)否 1该信息已成功保存!1)继续增加人员信息 2)回主菜单 3)退出 程序:#include<stdlib.h>#include <stdio.h>#include <string.h>struct staff/*定义结构体*/ char num10;/*编号*/ char name20;/*姓名*/ char sex10;/*性别*/ int age;/*年龄*/ char duty20;/*职务*/ char title20;/*职称*/ char p_landscape30;/*政治面貌*/ char Qualifications30;/*

34、学历*/ 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%-7s%-5s%-8s%-

35、12s%-5d%-12s%-3sn",p.num,,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

36、%s %s %s %s %d %s %sn",staffi.num,,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")

37、;/*清屏*/n=load(); do fflush(stdin); /*清除缓冲区输入*/ printf(" 通过1)编号 2)姓名 bb"); w0=getchar(); while(w0<'1'|w0>'2'); if(w0='1')/*按编号查找*/ flag=0; puts("输入人员编号:"); scanf("%s",s); for(i=0;i<n;i+) if(strcmp(s,staffi.num)=0) printf_face();printf_one

38、(staffi); flag=1;break; else continue; if(flag=0)puts("该人员不存在!"); else /*按姓名查找*/ flag=0; puts("输入人员姓名:"); scanf("%s",s); for(i=0;i<n;i+) if(strcmp(s,)=0) printf_face(); printf_one(staffi); flag=1;break; else continue; if(flag=0) puts("该人员不存在!");

39、return i;void save_all()/*保存所有数据函数*/int i; FILE *fp; if(fp=fopen("text.txt","wb")=NULL)printf("无法打开文件!");exit(0);for(i=0;i<n;i+)if(staffi.age!=0)fprintf(fp,"%s %s %s %d %s %s %s %s %d %s %sn",staffi.num,,staffi.sex,staffi.age,staffi.duty,staffi.t

40、itle,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;i<n;i+)if(strcmp(h,staffi.num)=0)puts("输入的编号有重复!请重新输入编号!");system("pause");return 1;return 0;void

41、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.sex,p.age,p.duty,p.title,p.p_landscape,p.Qualifications,p.Service_time,e_time,p.catego

42、ry); printf("该信息已成功保存!n");fclose(fp);/*修改模块*/void modify()int k=0,w0,g;char h30,w1,w2;loop: g=search_data(); if(g<n) do puts("ttt修改: 1)编号"); puts("ttt 2)姓名"); puts("ttt 3)性别"); puts("ttt 4)年龄"); puts("ttt 5)职务"); puts("ttt 6)职称"

43、;); puts("ttt 7)政治面貌"); puts("ttt 8)最高学历"); puts("ttt 9)任职时间"); puts("ttt 10)来院时间"); puts("ttt 11)人员类别"); printf(" 请选择 : bb"); scanf("%d",&w0);while(w0<1|w0>11); switch(w0) case 1:puts("请输入新编号:"); scanf("%

44、s",h);strcpy(staffg.num,h);break; case 2:puts("请输入姓名:"); scanf("%s",h);strcpy(,h);break; case 3:puts("请输入性别:"); scanf("%s",h);strcpy(staffg.sex,h);break; case 4:puts("请输入年龄:"); scanf("%d",&k);staffg.age=k;break; case 5:p

45、uts("请输入职务:"); 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);break; case 8:puts("请输入最高学历:"); scanf

46、("%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"

47、;,h);strcpy(staffg.category,h);break; do fflush(stdin); /*清除缓冲区输入*/ printf("是否保存?1)保存 2)否 bb"); w1=getchar();while(w1<'1'|w1>'2'); if(w1='1')save_all(); puts("保存修改成功!"); do fflush(stdin); /*清除缓冲区输入*/ printf("1)继续修改 2)回主菜单 3)退出 bb"); w2=getc

48、har();while(w2<'1'|w2>'3'); if(w2='1')goto loop; else if(w2='2')menu(); else exit(0); /*保存模块*/void save() char w0;save_all(); printf("所有信息已保存!n"); dofflush(stdin); /*清除缓冲区输入*/printf("1) 回主菜单 2) 退出 bb");w0=getchar();while(w0<'1'|w0&

49、gt;'2');if(w0='1')menu(); else exit(0);/*查找模块*/void search()int k;char w1;loop: k=search_data(); do fflush(stdin); /*清除缓冲区输入*/ printf("1)回主菜单 2)退出 3)继续查询 bb"); w1=getchar();while(w1<'1'|w1>'3'); if(w1='1')menu(); else if(w1='2')exit(0);

50、 else goto loop; /*增加模块*/void add()char w0,w1;loop: system("cls"); puts("请输入编号(如001):"); scanf("%s",s.num); if(test(s.num)goto loop;/*编号重复*/ puts("请输入姓名:"); scanf("%s",); puts("请输入性别(男,女):"); scanf("%s",s.sex); puts("请输

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

52、士学位 更高):"); scanf("%s",s.Qualifications); puts("请输入任职时间:"); scanf("%d",&s.Service_time); puts("请输入来院时间(如):"); scanf("%s",e_time); puts("请输入人员类别(行政人员 教师 一般员工 退休人员 临时工):"); scanf("%s",s.category); do fflush(stdin); /*清除缓冲区输入*/ printf("是否保存?1)是 2)否 bb"); w0=getchar();while(w0<'1'|w0>'2'); switch(w0-48) case 1:single_save(s);break; case 2:break; do fflush(stdin); /*清除缓冲区输入*/ printf("1)继续增加人员信息 2)回主菜单 3)退出 bb"); w1=getchar();while(w1

温馨提示

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

评论

0/150

提交评论