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个功能

#include <stdio.h>
#include <stdlib.h>
#include <string.h> struct emp{
int id;
char name[50];
struct emp * next;
// struct emp * prev;
}; struct emp * initList(); struct emp * addListTailNode(struct emp * head); struct emp * deleteListNode(struct emp * head,int id); struct emp * searchEmp(struct emp * head,int id); int printList(struct emp * l); int printNode(struct emp * p); struct emp * sortList(struct emp * head); int getListLen(struct emp * head); int writeToDisk(struct emp * head); struct emp * readFromDisk(); int menu(); int usage(struct emp * head);

#include "emp.h"

int main(){
struct emp * head;
head=readFromDisk();
usage(head);
return 0;
} struct emp * initList(){
struct emp * head;
head=(struct emp *)malloc(sizeof(struct emp));
head->next=NULL;
return head;
} struct emp * addListTailNode(struct emp * head){
int id;
char name[50];
struct emp * p, * last , * check;
last = head;
while(last->next!=NULL){
last=last->next;
}
printf("依次输入:员工id号,姓名!\n");
scanf("%d%s",&id,&name);
check = head;
while(check!=last){ //遍历
check=check->next;
if(id==check->id){
printf("加入�失败!员工id号反复!\n");
return head;
}
}
p=(struct emp *)malloc(sizeof(struct emp));
p->id=id;
strcpy(p->name,name);
//
last->next=p;
last=p;
p->next=NULL;
printf("%s员工信息已加入�!\n",p->name);
return head;
} struct emp * deleteListNode(struct emp * head,int id){
struct emp * p,* q;
p = head->next;
while(p!=NULL){
if(p->next->id==id){
break;
}
p=p->next;
}
if(head->next==NULL){
printf("书籍信息为空!删除失败!\n");
}
else{
q = p->next;
p->next = q->next;
printf("%s书籍信息被删除!\n",q->name);
free(q);
}
return head;
} struct emp * searchEmp(struct emp * head,int id){//查询,返回节点信息
struct emp * p;
p = head->next;
while(p!=NULL){
if(p->id==id){
break;
}
p=p->next;
}
return p;
} int printNode(struct emp * p){//打印节点信息
if(p!=NULL){
printf("员工id: %d 员工姓名:%s\n",p->id,p->name);
}
else{
printf("系统内无该员工信息!\n");
}
return 0;
} int printList(struct emp * head){ //打印整条链表
struct emp * p;
p = head->next;
while(p!=NULL){
printNode(p);
p=p->next;
}
return 0;
} struct emp * sortList(struct emp * head){//排序
struct emp * p,* q;
int temp_id;
char temp_name[50];
for(p=head->next;p!=NULL;p=p->next){
for(q=p->next;q!=NULL;q=q->next){
if(p->id>q->id){
temp_id = q->id;
q->id = p->id;
p->id = temp_id;
//
strcpy(temp_name,q->name);
strcpy(q->name,p->name);
strcpy(p->name,temp_name);
}
}
}
return head;
} int getListLen(struct emp * head){
int len=0;
struct emp * p;
p=head->next;
while(p!=NULL){
len++;
p=p->next;
}
return len;
} int writeToDisk(struct emp * head){
FILE * fp;
struct emp * p;
if((fp = fopen("D:\\emp.hhtx", "w")) == 0){
printf("写入失败……!\n");
return 0;
}
//
p=head->next;
while(p!=NULL){
fwrite(p,sizeof(struct emp),1,fp);
printf("%d %s\n",p->id,p->name);
p=p->next;
}
fclose(fp);
return 0;
} struct emp * readFromDisk(){
FILE * fp;
struct emp * head,* last,* p,* temp;
head = initList();
if((fp = fopen("D:\\emp.hhtx", "r")) == 0){
printf("载入失败……未找到存档数据!\n\n");
return head;
}
//
last = head;
p=(struct emp *)malloc(sizeof(struct emp));
while(p!=NULL){
p=(struct emp *)malloc(sizeof(struct emp));
fread(p,sizeof(struct emp),1,fp);
printf("读取数据: %d %s\n",p->id,p->name);
//
last->next=p;
last=p;
p=p->next;
}
fclose(fp);
printf("系统数据初始化完毕!");
return head;
} 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;
} int usage(struct emp * head){
int x,id;
struct emp * p;
menu();
while(1){
printf("请输入序列号:");
scanf("%d",&x);
switch(x){
case 1:
printf("输入所要查询的员工的id号:");
scanf("%d",&id);
p = searchEmp(head,id);
printNode(p);
printf("---------------------------------\n");
break;
case 2:
printf("系统中一共存在%d个员工\n",getListLen(head));
break;
case 3:
head=addListTailNode(head);
printf("---------------------------------\n");
break;
case 4:
printf("输入所要删除的员工的id号:");
scanf("%d",&id);
head=deleteListNode(head,id);
printf("---------------------------------\n");
break;
case 5:
printf("排序開始……\n");
head=sortList(head);
printf("排序已完毕!\n");
printf("---------------------------------\n");
break;
case 6:
printList(head);
printf("---------------------------------\n");
break;
case 7:
writeToDisk(head);
printf("保存完毕……\n");
printf("已退出系统!\n");
printf("---------------------------------\n");
return 0;
default:
return 0;
}
}
return 0;
}

人事管理系统 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. 几种能在O(n*log(n))时间排序

    线性时间排序   各种排序算法总结已经介绍了几种能在O(n*log(n))时间内培训n个数的算法.归并排序和堆排序达到了最坏情况下的上界:快速排序在平均情况下达到该上界.这些算法都有一个有趣的性质:在 ...

  2. keepalive的 nopreempt 非抢占

    通常如果master服务死掉后backup会变成master,但是当master服务又好了的时候 master此时会抢占VIP,这样就会发生两次切换对业务繁忙的网站来说是不好的.所以我们要在配置文件加 ...

  3. 简单的http代理服务器

    简单的http代理服务器 本项目课程是基于 Python 实现的一个简单的 HTTP 代理服务器,要求用户需了解 Python 基础和一定的 HTTP 服务器基础知识.

  4. NGUI 3.5教程(二)Label 标签 (Hello world)、多行文本

    写在前面:     本文将创建NGUI的第一个样例.依照编程传统,第一个样例,就是做一个Hello world 显示出来.NGUI.我们用Label来实现 . 欢迎大家纠错.拍砖!原创非常辛苦,如有转 ...

  5. 新书:《Liferay Portal 6.1最佳实践门户网站建设》

    新书:<Liferay Portal 6.1最佳实践门户网站建设>   <Liferay Portal 6.1门户站点建设最佳实践>是国内第一本全面介绍Liferay Port ...

  6. Swift UI开发初探

    今天凌晨Apple刚刚发布了Swift编程语言,Swift是供iOS和OS X应用编程的新编程语言.相信很多开发者都在学习这门新语言. 废话不多说,下面我就来学习使用Swift创建一个简单的UI应用程 ...

  7. openssl生成pem,密钥证书的创建

    使用OpenSSL生成证书 首先得安装OpenSSL软件包openssl,安装了这个软件包之后,我们可以做这些事情: o Creation of RSA, DH and DSA Key Paramet ...

  8. Ajax技术——带进度条的文件上传

    1.概述 在实际的Web应该开发或网站开发过程中,经常需要实现文件上传的功能.在文件上传过程中,经常需要用户进行长时间的等待,为了让用户及时了解上传进度,可以在上传文件的同时,显示文件的上传进度条.运 ...

  9. [置顶] Android下实现自动关机的方法总结

    最近在网上看了一些Android下实现自动关机的方法,有的不行,有的只适用一些机型,有的适用于大部分机型,笔者在此总结一下 法一: Intent newIntent = new Intent(Inte ...

  10. os内存使用管理之unix-AIX篇

    os内存使用管理之unix-AIX篇 未完待补充.....