这篇文章主要为大家详细介绍了C++职工管理系统实训代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了C++职工管理系统实例代码
1.单个职工的头文件
staff.h
#ifndef STAFF_H_INCLUDED
#define STAFF_H_INCLUDED
//结构体创建
struct staff
{
char ID[10];
char name[10];
char sex[10];
int pay;
int reward;
int factpay;
};
//自定义结构体
typedef struct staff staff;
//单个职工信息创建
staff Createstaff();
//单个职工信息输出
void Displaystaff(staff staff);
//修改职工信息
void updatestaff(staff *Staff);
#endif // STAFF_H_INCLUDED
单个职工的cpp文件
staff.cpp
#include <stdio.h>
#include <stdlib.h>
#include "staff.h"
staff Createstaff()
{
staff staff;
printf("-----------ID-----------n");
scanf("%s", staff.ID);
printf("-----------name-----------n");
scanf("%s", staff.name);
printf("-----------sex-----------n");
scanf("%s", staff.sex);
printf("-----------pay-----------n");
scanf("%d", &staff.pay);
printf("-----------reward-----------n");
scanf("%d", &staff.reward);
staff.factpay = staff.pay + staff.reward;
printf("n");
return staff;
}
void Displaystaff(staff staff)
{
printf("%10s", staff.ID);
printf("%10s", staff.name);
printf("%10s", staff.sex);
printf("%10d", staff.pay);
printf("%10d", staff.reward);
printf("%10d", staff.factpay);
printf("n");
}
void updatestaff(staff *Staff)
{
printf("-----请显示要修改的数据--------n");
Displaystaff(*Staff);
printf("-------请输入要修改的数据---------");
printf("-----------pay-----------n");
scanf("%d", &Staff->pay);
printf("-----------reward-----------n");
scanf("%d", &Staff->reward);
Staff->factpay = Staff->pay + Staff->reward;
printf("n");
}
2.链表的创建
链表的头文件
linklist.h
#ifndef LINKLIST_H_INCLUDED
#define LINKLIST_H_INCLUDED
#include "staff.h"
//链表结点创建
struct Node
{
struct staff Staff;
struct Node *next;
};
//自定义结点
typedef struct Node node;
typedef struct Node *linklist;
//创建链表
node *Createlinklist();
//输出链表中的数据
void Displaylinklist(node *head);
//按职工号查找职工
node *searchnode(node *head, char ID[]);
//按姓名查找职工
void searchnodebyname(node *head, char name[]);
//删除职工
void delenode(linklist head, char ID[]);
//插入职工
void insertnode(linklist head, staff Staff);
//链表销毁
void distroylinklist(linklist head);
#endif // LINKLIST_H_INCLUDED










