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.  
  5. struct emp{
  6. int id;
  7. char name[50];
  8. struct emp * next;
  9. // struct emp * prev;
  10. };
  11.  
  12. struct emp * initList();
  13.  
  14. struct emp * addListTailNode(struct emp * head);
  15.  
  16. struct emp * deleteListNode(struct emp * head,int id);
  17.  
  18. struct emp * searchEmp(struct emp * head,int id);
  19.  
  20. int printList(struct emp * l);
  21.  
  22. int printNode(struct emp * p);
  23.  
  24. struct emp * sortList(struct emp * head);
  25.  
  26. int getListLen(struct emp * head);
  27.  
  28. int writeToDisk(struct emp * head);
  29.  
  30. struct emp * readFromDisk();
  31.  
  32. int menu();
  33.  
  34. int usage(struct emp * head);

  1. #include "emp.h"
  2.  
  3. int main(){
  4. struct emp * head;
  5. head=readFromDisk();
  6. usage(head);
  7. return 0;
  8. }
  9.  
  10. struct emp * initList(){
  11. struct emp * head;
  12. head=(struct emp *)malloc(sizeof(struct emp));
  13. head->next=NULL;
  14. return head;
  15. }
  16.  
  17. struct emp * addListTailNode(struct emp * head){
  18. int id;
  19. char name[50];
  20. struct emp * p, * last , * check;
  21. last = head;
  22. while(last->next!=NULL){
  23. last=last->next;
  24. }
  25. printf("依次输入:员工id号,姓名!\n");
  26. scanf("%d%s",&id,&name);
  27. check = head;
  28. while(check!=last){ //遍历
  29. check=check->next;
  30. if(id==check->id){
  31. printf("加入�失败!员工id号反复!\n");
  32. return head;
  33. }
  34. }
  35. p=(struct emp *)malloc(sizeof(struct emp));
  36. p->id=id;
  37. strcpy(p->name,name);
  38. //
  39. last->next=p;
  40. last=p;
  41. p->next=NULL;
  42. printf("%s员工信息已加入�!\n",p->name);
  43. return head;
  44. }
  45.  
  46. struct emp * deleteListNode(struct emp * head,int id){
  47. struct emp * p,* q;
  48. p = head->next;
  49. while(p!=NULL){
  50. if(p->next->id==id){
  51. break;
  52. }
  53. p=p->next;
  54. }
  55. if(head->next==NULL){
  56. printf("书籍信息为空!删除失败!\n");
  57. }
  58. else{
  59. q = p->next;
  60. p->next = q->next;
  61. printf("%s书籍信息被删除!\n",q->name);
  62. free(q);
  63. }
  64. return head;
  65. }
  66.  
  67. struct emp * searchEmp(struct emp * head,int id){//查询,返回节点信息
  68. struct emp * p;
  69. p = head->next;
  70. while(p!=NULL){
  71. if(p->id==id){
  72. break;
  73. }
  74. p=p->next;
  75. }
  76. return p;
  77. }
  78.  
  79. int printNode(struct emp * p){//打印节点信息
  80. if(p!=NULL){
  81. printf("员工id: %d 员工姓名:%s\n",p->id,p->name);
  82. }
  83. else{
  84. printf("系统内无该员工信息!\n");
  85. }
  86. return 0;
  87. }
  88.  
  89. int printList(struct emp * head){ //打印整条链表
  90. struct emp * p;
  91. p = head->next;
  92. while(p!=NULL){
  93. printNode(p);
  94. p=p->next;
  95. }
  96. return 0;
  97. }
  98.  
  99. struct emp * sortList(struct emp * head){//排序
  100. struct emp * p,* q;
  101. int temp_id;
  102. char temp_name[50];
  103. for(p=head->next;p!=NULL;p=p->next){
  104. for(q=p->next;q!=NULL;q=q->next){
  105. if(p->id>q->id){
  106. temp_id = q->id;
  107. q->id = p->id;
  108. p->id = temp_id;
  109. //
  110. strcpy(temp_name,q->name);
  111. strcpy(q->name,p->name);
  112. strcpy(p->name,temp_name);
  113. }
  114. }
  115. }
  116. return head;
  117. }
  118.  
  119. int getListLen(struct emp * head){
  120. int len=0;
  121. struct emp * p;
  122. p=head->next;
  123. while(p!=NULL){
  124. len++;
  125. p=p->next;
  126. }
  127. return len;
  128. }
  129.  
  130. int writeToDisk(struct emp * head){
  131. FILE * fp;
  132. struct emp * p;
  133. if((fp = fopen("D:\\emp.hhtx", "w")) == 0){
  134. printf("写入失败……!\n");
  135. return 0;
  136. }
  137. //
  138. p=head->next;
  139. while(p!=NULL){
  140. fwrite(p,sizeof(struct emp),1,fp);
  141. printf("%d %s\n",p->id,p->name);
  142. p=p->next;
  143. }
  144. fclose(fp);
  145. return 0;
  146. }
  147.  
  148. struct emp * readFromDisk(){
  149. FILE * fp;
  150. struct emp * head,* last,* p,* temp;
  151. head = initList();
  152. if((fp = fopen("D:\\emp.hhtx", "r")) == 0){
  153. printf("载入失败……未找到存档数据!\n\n");
  154. return head;
  155. }
  156. //
  157. last = head;
  158. p=(struct emp *)malloc(sizeof(struct emp));
  159. while(p!=NULL){
  160. p=(struct emp *)malloc(sizeof(struct emp));
  161. fread(p,sizeof(struct emp),1,fp);
  162. printf("读取数据: %d %s\n",p->id,p->name);
  163. //
  164. last->next=p;
  165. last=p;
  166. p=p->next;
  167. }
  168. fclose(fp);
  169. printf("系统数据初始化完毕!");
  170. return head;
  171. }
  172.  
  173. int menu(){
  174. printf("请按提示输入完毕操作!\n");
  175. printf("1.查询员工信息\n");
  176. printf("2.统计员工数量\n");
  177. printf("3.录入员工信息\n");
  178. printf("4.删除员工信息\n");
  179. printf("5.按id排序全部员工\n");
  180. printf("6.打印全部员工信息\n");
  181. printf("7.退出系统\n");
  182. return 0;
  183. }
  184.  
  185. int usage(struct emp * head){
  186. int x,id;
  187. struct emp * p;
  188. menu();
  189. while(1){
  190. printf("请输入序列号:");
  191. scanf("%d",&x);
  192. switch(x){
  193. case 1:
  194. printf("输入所要查询的员工的id号:");
  195. scanf("%d",&id);
  196. p = searchEmp(head,id);
  197. printNode(p);
  198. printf("---------------------------------\n");
  199. break;
  200. case 2:
  201. printf("系统中一共存在%d个员工\n",getListLen(head));
  202. break;
  203. case 3:
  204. head=addListTailNode(head);
  205. printf("---------------------------------\n");
  206. break;
  207. case 4:
  208. printf("输入所要删除的员工的id号:");
  209. scanf("%d",&id);
  210. head=deleteListNode(head,id);
  211. printf("---------------------------------\n");
  212. break;
  213. case 5:
  214. printf("排序開始……\n");
  215. head=sortList(head);
  216. printf("排序已完毕!\n");
  217. printf("---------------------------------\n");
  218. break;
  219. case 6:
  220. printList(head);
  221. printf("---------------------------------\n");
  222. break;
  223. case 7:
  224. writeToDisk(head);
  225. printf("保存完毕……\n");
  226. printf("已退出系统!\n");
  227. printf("---------------------------------\n");
  228. return 0;
  229. default:
  230. return 0;
  231. }
  232. }
  233. return 0;
  234. }

人事管理系统 c语言版的更多相关文章

  1. 教你做一个单机版人事管理系统(Winform版)treeview与listview使用详情

    ------------------------------------------------------------------部门部分------------------------------ ...

  2. JAVA课程设计——一个简单的教务人事管理系统

    大三上学期期末总结,没错,上学期,写在下学期新学期开始,哈哈哈. 上学期学习了面向对象程序设计,课程设计的题目使用JAVA语言完成一个简单的教务人事管理系统,能够实现访问数据库的登录验证,分别按部门和 ...

  3. 基于Spring MVC + Spring + MyBatis的【人事管理系统】

    资源下载:https://download.csdn.net/download/weixin_44893902/33163160 一.语言和环境 实现语言:JAVA语言 环境要求:IDEA/Eclip ...

  4. 团队编程——web应用之人事管理系统

    本次作业为团队作业,团队博客要求如下:1. 介绍团队情况:包括队长.成员.队名.成员照片.队训--.等:2. 介绍团队项目名称.总体任务,各成员任务等:3. 每个队做 一次需求调研(针对团队项目),要 ...

  5. libnode 0.4.0 发布,C++ 语言版的 Node.js

    libnode 0.4.0 支持 Windows ,提升了性能,libuv 更新到 0.10.17 版本,libj 更新到 0.8.2 版本. libnode 是 C++ 语言版的 Node.js,和 ...

  6. md5加密算法c语言版

    from: http://blog.sina.com.cn/s/blog_693de6100101kcu6.html 注:以下是md5加密算法c语言版(16/32位) ---------------- ...

  7. 基于gSOAP使用头文件的C语言版web service开发过程例子

    基于gSOAP使用头文件的C语言版web service开发过程例子 一服务端 1 打开VS2005,创建一个工程,命名为calcServer. 2 添加一个头文件calc.h,编辑内容如下: 1// ...

  8. MFC原创:三层架构01(人事管理系统)DAL

    VC++/MFC Window编程原创教程文件夹 C++课程设计来着.但还没学过数据,也还没理解过三层架构,就把这个作业深化点来做了.尽管要做的这个人事管理系统看起来是挺简单的,无非就是处理员工信息. ...

  9. Windows 8.1 with Update 镜像下载(增OEM单语言版)

    该系统已有更新的版本,请转至<Windows 8.1 with update 官方最新镜像汇总>下载. 2014年4月9日凌晨,微软向MSDN订阅用户开放了Windows 8.1 with ...

随机推荐

  1. ListView属性解释

    1.android:scrollbarStyle 定义滚动条的样式和位置 参考:http://www.trinea.cn/android/android-scrollbarstyle/ 2.andro ...

  2. 获取sdcard和内存的存储空间

    package com.example.sdcardspace; import java.io.File; import android.os.Bundle; import android.os.En ...

  3. JFinal教程1——小白的第一个JFinal程序

    为了使小白能够完全的按步骤创建第一个JFinal应用并运行,笔者将以Java界最流行的Eclipse平台为例,搭建出所有基础教程中喜欢的Hello world应用. 1. JFinal简介 2. 小白 ...

  4. [转]在linux下如何判断是否已经安装某个软件?软件安装在哪个目录

    <1>在linux下如何判断是否已经安装某个软件? ++++++++++++++++++++++++++++++++++++++++++ rpm -qa|grep 软件包 ++++++++ ...

  5. Netty开发实现高性能的RPC服务器

    Netty开发实现高性能的RPC服务器 RPC(Remote Procedure Call Protocol)远程过程调用协议,它是一种通过网络,从远程计算机程序上请求服务,而不必了解底层网络技术的协 ...

  6. listview滑动

    单击其中的一个item时,让这个item能滚动的listview的顶部.现在用 list.scrollTo(0, item.getTop()); 实现啦 android listview滚动到顶部 转 ...

  7. Docker学习笔记(3) — docker仓库的镜像怎么删除

    docker越来越炙手可热,如果你的团队已经准备开始使用docker,那么私有仓库是必不可少的东西,首先是可以帮助你加快从服务器pull镜像的速度,其次也可以帮助你存放私有的镜像,本文主要为大家介绍如 ...

  8. java.lang.NoClassDefFoundError: org/apache/lucene/analysis/synonym/SynonymFilter

    2013-6-24 13:28:51 org.apache.solr.common.SolrException log 严重: java.lang.NoClassDefFoundError: org/ ...

  9. H3C HCSE 官方培训胶片(中文) 下载

    H3C HCSE 官方培训胶片(中文) 点击文件名下载 HM-040 OSPF路由协议(V5.1).ppt HM-041 BGP协议原理及配置(V5.0).ppt HM-041 BGP协议原理及配置( ...

  10. Spring MVC 的json问题(406 Not Acceptable)

    原因 : 就是程序转换JSON失败. 在pom.xml 加上 <dependency> <groupId>com.fasterxml.jackson.core</grou ...