人事管理系统 c语言版_人事信息管理系统c

人事管理系统 c语言版_人事信息管理系统c

int menu(){
printf("请按提示输入完成操作!\n");
printf("1.查询员工信息\n");
printf("2.统计员工数量\n");
printf("3.录入员工信息\n");
printf("4.删除员工信息\n");
printf("5.按id排序所有员工\n");
printf("6.打印所有员工信息\n");
printf("7.退出系统\n");
return 0;

}

如menu()函数所示,该系统一共有7个功能

  1. #include <stdio.h>

  2. #include <stdlib.h>

  3. #include <string.h>

  4. struct emp{

  5. int id;

  6. char name[50];

  7. struct emp * next;

  8. };

  9. struct emp * initList();

  10. struct emp * addListTailNode(struct emp * head);

  11. struct emp * deleteListNode(struct emp * head,int id);

  12. struct emp * searchEmp(struct emp * head,int id);

  13. int printList(struct emp * l);

  14. int printNode(struct emp * p);

  15. struct emp * sortList(struct emp * head);

  16. int getListLen(struct emp * head);

  17. int writeToDisk(struct emp * head);

  18. struct emp * readFromDisk();

  19. int menu();

  20. int usage(struct emp * head);

 

  1. #include "emp.h"

  2. int main(){

  3. struct emp * head;

  4. head=readFromDisk();

  5. usage(head);

  6. return 0;

  7. }

  8. struct emp * initList(){

  9. struct emp * head;

  10. head=(struct emp *)malloc(sizeof(struct emp));

  11. head->next=NULL;

  12. return head;

  13. }

  14. struct emp * addListTailNode(struct emp * head){

  15. int id;

  16. char name[50];

  17. struct emp * p, * last , * check;

  18. last = head;

  19. while(last->next!=NULL){

  20. last=last->next;

  21. }

  22. printf("依次输入:员工id号,姓名!\n");

  23. scanf("%d%s",&id,&name);

  24. check = head;

  25. while(check!=last){

  26. check=check->next;

  27. if(id==check->id){

  28. printf("添加失败!员工id号重复!\n");

  29. return head;

  30. }

  31. }

  32. p=(struct emp *)malloc(sizeof(struct emp));

  33. p->id=id;

  34. strcpy(p->name,name);

  35. last->next=p;

  36. last=p;

  37. p->next=NULL;

  38. printf("%s员工信息已添加!\n",p->name);

  39. return head;

  40. }

  41. struct emp * deleteListNode(struct emp * head,int id){

  42. struct emp * p,* q;

  43. p = head->next;

  44. while(p!=NULL){

  45. if(p->next->id==id){

  46. break;

  47. }

  48. p=p->next;

  49. }

  50. if(head->next==NULL){

  51. printf("书籍信息为空!删除失败!\n");

  52. }

  53. else{

  54. q = p->next;

  55. p->next = q->next;

  56. printf("%s书籍信息被删除!\n",q->name);

  57. free(q);

  58. }

  59. return head;

  60. }

  61. struct emp * searchEmp(struct emp * head,int id){

  62. struct emp * p;

  63. p = head->next;

  64. while(p!=NULL){

  65. if(p->id==id){

  66. break;

  67. }

  68. p=p->next;

  69. }

  70. return p;

  71. }

  72. int printNode(struct emp * p){

  73. if(p!=NULL){

  74. printf("员工id: %d 员工姓名:%s\n",p->id,p->name);

  75. }

  76. else{

  77. printf("系统内无该员工信息!\n");

  78. }

  79. return 0;

  80. }

  81. int printList(struct emp * head){

  82. struct emp * p;

  83. p = head->next;

  84. while(p!=NULL){

  85. printNode(p);

  86. p=p->next;

  87. }

  88. return 0;

  89. }

  90. struct emp * sortList(struct emp * head){

  91. struct emp * p,* q;

  92. int temp_id;

  93. char temp_name[50];

  94. for(p=head->next;p!=NULL;p=p->next){

  95. for(q=p->next;q!=NULL;q=q->next){

  96. if(p->id>q->id){

  97. temp_id = q->id;

  98. q->id = p->id;

  99. p->id = temp_id;

  100. strcpy(temp_name,q->name);

  101. strcpy(q->name,p->name);

  102. strcpy(p->name,temp_name);

  103. }

  104. }

  105. }

  106. return head;

  107. }

  108. int getListLen(struct emp * head){

  109. int len=0;

  110. struct emp * p;

  111. p=head->next;

  112. while(p!=NULL){

  113. len++;

  114. p=p->next;

  115. }

  116. return len;

  117. }

  118. int writeToDisk(struct emp * head){

  119. FILE * fp;

  120. struct emp * p;

  121. if((fp = fopen("D:\\emp.hhtx", "w")) == 0){

  122. printf("写入失败……!\n");

  123. return 0;

  124. }

  125. p=head->next;

  126. while(p!=NULL){

  127. fwrite(p,sizeof(struct emp),1,fp);

  128. printf("%d %s\n",p->id,p->name);

  129. p=p->next;

  130. }

  131. fclose(fp);

  132. return 0;

  133. }

  134. struct emp * readFromDisk(){

  135. FILE * fp;

  136. struct emp * head,* last,* p,* temp;

  137. head = initList();

  138. if((fp = fopen("D:\\emp.hhtx", "r")) == 0){

  139. printf("加载失败……未找到存档数据!\n\n");

  140. return head;

  141. }

  142. last = head;

  143. p=(struct emp *)malloc(sizeof(struct emp));

  144. while(p!=NULL){

  145. p=(struct emp *)malloc(sizeof(struct emp));

  146. fread(p,sizeof(struct emp),1,fp);

  147. printf("读取数据: %d %s\n",p->id,p->name);

  148. last->next=p;

  149. last=p;

  150. p=p->next;

  151. }

  152. fclose(fp);

  153. printf("系统数据初始化完成!");

  154. return head;

  155. }

  156. int menu(){

  157. printf("请按提示输入完成操作!\n");

  158. printf("1.查询员工信息\n");

  159. printf("2.统计员工数量\n");

  160. printf("3.录入员工信息\n");

  161. printf("4.删除员工信息\n");

  162. printf("5.按id排序所有员工\n");

  163. printf("6.打印所有员工信息\n");

  164. printf("7.退出系统\n");

  165. return 0;

  166. }

  167. int usage(struct emp * head){

  168. int x,id;

  169. struct emp * p;

  170. menu();

  171. while(1){

  172. printf("请输入序列号:");

  173. scanf("%d",&x);

  174. switch(x){

  175. case 1:

  176. printf("输入所要查询的员工的id号:");

  177. scanf("%d",&id);

  178. p = searchEmp(head,id);

  179. printNode(p);

  180. printf("---------------------------------\n");

  181. break;

  182. case 2:

  183. printf("系统中一共存在%d个员工\n",getListLen(head));

  184. break;

  185. case 3:

  186. head=addListTailNode(head);

  187. printf("---------------------------------\n");

  188. break;

  189. case 4:

  190. printf("输入所要删除的员工的id号:");

  191. scanf("%d",&id);

  192. head=deleteListNode(head,id);

  193. printf("---------------------------------\n");

  194. break;

  195. case 5:

  196. printf("排序开始……\n");

  197. head=sortList(head);

  198. printf("排序已完成!\n");

  199. printf("---------------------------------\n");

  200. break;

  201. case 6:

  202. printList(head);

  203. printf("---------------------------------\n");

  204. break;

  205. case 7:

  206. writeToDisk(head);

  207. printf("保存完成……\n");

  208. printf("已退出系统!\n");

  209. printf("---------------------------------\n");

  210. return 0;

  211. default:

  212. return 0;

  213. }

  214. }

  215. return 0;

  216. }

 

人事管理系统 c语言版_人事信息管理系统c

人事管理系统 c语言版_人事信息管理系统c

阅读剩余 92%

原创文章,作者:192.168.1.1,如若转载,请注明出处:https://www.224m.com/229987.html

(0)
192.168.1.1192.168.1.1
上一篇 2022年11月7日 12:04
下一篇 2022年11月7日 12:10

相关推荐

  • 电脑一键还原按f几 笔记本电脑怎么一键恢复?

    电脑一键还原按f几 一键还原的镜像文件在哪里?笔记本电脑怎么一键恢复? 你是用的F一键还原吗?如果是,你看不到备份文件,因为F安装时自动从最后一个盘子中分离411键还原G左右空间设置为隐藏分区,以

    投稿 2022年7月23日
  • eclipse配置pyqt python的ide不包括?

    eclipse配置pyqt eclipse配置?python的ide不包括? 1、首先在电脑中,解压Eclipse压缩包。2、进入解压后eclipse在文件夹下,双击文件夹eclipse使其运行。

    投稿 2022年7月9日
  • 杨浦区重点小学排名 杨浦区有哪几个小学?

    杨浦区重点小学排名 上海杨浦区小学排名2020?杨浦区有哪几个小学? 上海杨浦区重点小学有哪些排名?以下是学校排名榜为您准备的相关内容,希望对您有所帮助! 1.杨浦区虎山路一小学特色:艺

    投稿 2022年7月10日
  • 腾达路由器设置 腾达路由器怎么打开?

    腾达路由器设置 如何安装和设置腾达路由器的密码?腾达路由器怎么打开? 无线路由器的设置方法基本相同。以腾达无线路由器的设置为例,其他路由器也可以参考。。方法步骤如下:如果有无线路由器,先连接电源,

    投稿 2022年7月12日
  • 京东配送跟踪查询 京东快递怎么跟踪查询?

    JD.COM配送跟踪查询 开网店有以下问题:如何一次查询百世、中通快递、大云等大量物流快递?JD.COM、淘宝和品多多批量跟踪在途物流,哪个查询助手会更方便查询?JD.COM快递如何跟踪查询?

    投稿 2022年7月19日
  • 虚拟主机空间购买 怎么在虚拟空间登录谷歌?

    虚拟主机空间购买 实体空间和虚拟空间有什么区别?怎么在虚拟空间登录谷歌? 实体空间的特点是空间范围清晰,私密性强;虚拟空间的特点是空间范围不明确,私密性小,位于实体空间。又称空间中的空间或心理空间

    投稿 2022年7月23日
  • 文件怎么上传到中转站 文件中转怎么用?

    文件怎么上传到中转站 如何将我的邮件转移到文件中转站?文件中转怎么用? 首先,将邮件中的文件下载到当地磁盘上然后打开邮箱首页的文件中转站点击中转站页面上的上传文件按钮然后弹出上传文件对话框点击浏览

    投稿 2022年7月7日
  • 如何查看共享文件 共享目录怎么设置?

    如何查看共享文件 如何在其他电脑上查看共享文件夹?共享目录怎么设置? 在别人的电脑上访问共享文件夹的具体步骤如下: 我们需要准备的材料是:电脑,局域网。首先,我们在网上邻居中打开查看工作组计算机。

    投稿 2022年7月20日
  • 电子商务专业就业方向 怎么介绍电子商务专业?

    电子商务专业就业方向 电子商务专业是一门综合性学科,学的东西很多,也很杂。不仅要学习计算机相关技术,还要学习专业基础知识和商务相关课程。怎么介绍电子商务专业? 什么是电子商务?电子商务是指以信息网

    投稿 2022年7月10日
  • 智能产品有哪些 有哪些性价比高的智能家居推荐?

    智能产品有哪些 智能电子产品有哪些?有哪些性价比高的智能家居推荐? 1.手机:全称移动电话或无线电话,通常称为手机。只是一种通讯工具。早期俗称大哥大,是一种可广泛使用的便携式电话终端。最早是由19

    投稿 2022年7月6日