人事管理系统 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

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

(0)
192.168.1.1192.168.1.1
c语言人事管理系统,c语言人事管理系统
上一篇 2022年11月7日 12:04
192.168.0.1手机登录入口(192.168.0.1 登陆页面)
下一篇 2022年11月7日 12:10

相关推荐

  • 跃层用什么路由器好?(我应该用什么路由器跳到地板上?)

    问:我家是跳房子。现在路由器在楼下客厅,楼上卧室wifi信号不太好。请问什么路由器适合跳楼,可以让楼上的wifi信号很好? 你好,一栋带跳楼的房子。如果每层面积比较大,建议使用分布…

    常见问题 2022年2月21日
    5.0K
  • 电脑屏幕有时候会有条纹不断闪烁解决方法

    原标题:"电脑屏幕有时候会有条纹不断闪烁怎么解决"相关电脑问题教程分享。 - 来源:WiFi之家网。电脑用久了就容易出现问题,特别是屏幕,有用户反应,电脑屏幕会出现闪烁条纹是怎么回事呢?怎么解决电脑屏幕

    2021年8月28日
    8.6K
  • 教你如何设置路由器控制别人网速

    原标题:"怎么设置路由器控制别人网速"的相关路由器设置教程资料分享。- 来源:WiFi之家网。

    现在我们应该经常会有很多人一起用路由器的情况吧,尤其是当我们网速不快的,而我"

    路由器设置 2021年2月2日
    10.8K
  • 请修改路由器无线设置名称(普联路由器修改无线密码)

    请修改路由器无线设置名称(普联路由器修改无线密码) 在家庭或办公室中使用无线网络已成为常态,因此为了提高网络安全性,建议修改无线网络名称和密码。以下是普联路由器修改无线密码的详细操…

    网络 2023年12月21日
    7.1K
  • 设置路由器要先接线吗(先设置猫还是路由器)

    在设置路由器前,我们需要明确一点,那就是路由器需要连接网络信号才能正常工作,而这个信号一般来自于网络提供商的猫(光纤猫、ADSL猫等)。因此,我们需要先接线。 具体来说,接线的步骤…

    网络 2024年11月18日
    9.0K
  • 魅族硬盘路由器怎么设置(带硬盘的小米路由器怎么设置)

    魅族硬盘路由器怎么设置 魅族硬盘路由器可以让用户通过局域网内的设备共享硬盘上的文件,以下是设置步骤: 将硬盘插入路由器的USB接口 连接路由器,打开浏览器,在地址栏输入路由器IP地…

    网络 2023年12月14日
    8.0K
  • Win7开机提示账户已被停用如何解决

    原标题:"Win7系统电脑开机提示账户已被停用的解决方法"相关电脑问题教程分享。 - 来源:WiFi之家网。Win7系统电脑开机后显示账户已被停用,不能进入系统桌面怎么办?最近有用户在开机后发现,电脑账

    2021年8月19日
    5.5K
  • 手机卡变成2g解决方法(图文)

    【导读】手机卡变成2g怎么回事,下面就是WiFi之家网整理的网络知识百科,来看看吧!大家好,我是191路由器网小编,上述问题将由我为大家讲解。手机卡变成2g的原因有:  1、可能是手机上网超过40gb被

    2021年7月30日
    460.2K
  • 磁盘键盘鼠标设备管理(鼠标设备管理器)

    摘要 设备控制器 IO控制方式 设备驱动程序 存储系统IO分层 设备控制器 为什么需要设备控制器? 电脑可以外接很多设备,如键盘、鼠标、硬盘、显示器、网卡等,每个设备的用法和功能不…

    2023年2月8日
    8.3K
  • 电脑上显示尚未安装打印机怎么解决

    原标题:"WinXP系统提示尚未安装打印机的解决方法"相关电脑问题教程分享。 - 来源:WiFi之家网。XP系统电脑提示尚未安装打印机怎么办?如何解决XP系统电脑提示尚未安装打印机的问题?下面就给大家分

    2021年8月11日
    22.1K