1、职工信息管理系统设计 职工信息包括职工号、姓名、性别、年龄、学历、工资、住址、电话等。试设计一职工信息管理系统,使之能提供以下功能: 系统以菜单方式工作:(用键盘输入1~6之间的 数来选择功能) (1) 职工信息录入功能(职工信息用文件保 存) (2) 职工信息浏览功能 (3)查询功能:按工号和按学历查询 (4)信息删除功能:按职工姓名删除 (5) 信息修改功能:把研究生学历的职工工资增加500元。 (6)退出。
时间: 2023-12-19 17:17:45 浏览: 104
好的,这是一个比较简单的职工信息管理系统,可以通过C语言实现。以下是系统的基本设计思路:
1. 定义职工信息结构体,包含职工号、姓名、性别、年龄、学历、工资、住址、电话等信息。
2. 定义菜单函数,让用户通过键盘输入1-6之间的数字选择功能。
3. 实现职工信息录入功能,将职工信息以文件的形式保存到磁盘中。
4. 实现职工信息浏览功能,可以将职工信息从文件中读取并输出到屏幕上。
5. 实现查询功能,可以根据工号或学历查询职工信息,并输出到屏幕上。
6. 实现信息删除功能,可以根据职工姓名删除职工信息,并将更新后的职工信息重新保存到磁盘中。
7. 实现信息修改功能,可以将研究生学历的职工工资增加500元,并将更新后的职工信息重新保存到磁盘中。
8. 实现退出功能,让用户可以选择退出系统。
以下是一个简单的代码示例:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_WORKER_NUM 100
// 职工信息结构体
typedef struct {
char id[10]; // 职工号
char name[20]; // 姓名
char sex[10]; // 性别
int age; // 年龄
char education[20]; // 学历
int salary; // 工资
char address[50]; // 住址
char phone[20]; // 电话
} Worker;
// 菜单函数
void menu() {
printf("==========职工信息管理系统==========\n");
printf("1. 职工信息录入\n");
printf("2. 职工信息浏览\n");
printf("3. 查询职工信息\n");
printf("4. 删除职工信息\n");
printf("5. 修改职工信息\n");
printf("6. 退出系统\n");
printf("请输入数字选择功能:");
}
// 录入职工信息
void addWorker(Worker *workers, int *count) {
if (*count >= MAX_WORKER_NUM) {
printf("职工信息已满,无法继续录入!\n");
return;
}
printf("请输入职工信息:\n");
printf("职工号:");
scanf("%s", workers[*count].id);
printf("姓名:");
scanf("%s", workers[*count].name);
printf("性别:");
scanf("%s", workers[*count].sex);
printf("年龄:");
scanf("%d", &workers[*count].age);
printf("学历:");
scanf("%s", workers[*count].education);
printf("工资:");
scanf("%d", &workers[*count].salary);
printf("住址:");
scanf("%s", workers[*count].address);
printf("电话:");
scanf("%s", workers[*count].phone);
(*count)++;
printf("职工信息录入成功!\n");
}
// 浏览职工信息
void viewWorkers(Worker *workers, int count) {
if (count == 0) {
printf("暂无职工信息!\n");
return;
}
printf("职工信息如下:\n");
printf("职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t\t电话\n");
for (int i = 0; i < count; i++) {
printf("%s\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",
workers[i].id, workers[i].name, workers[i].sex, workers[i].age, workers[i].education, workers[i].salary, workers[i].address, workers[i].phone);
}
}
// 按工号查询职工信息
void searchById(Worker *workers, int count) {
char id[10];
printf("请输入要查询的职工号:");
scanf("%s", id);
for (int i = 0; i < count; i++) {
if (strcmp(workers[i].id, id) == 0) {
printf("职工信息如下:\n");
printf("职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t\t电话\n");
printf("%s\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",
workers[i].id, workers[i].name, workers[i].sex, workers[i].age, workers[i].education, workers[i].salary, workers[i].address, workers[i].phone);
return;
}
}
printf("未找到该职工信息!\n");
}
// 按学历查询职工信息
void searchByEducation(Worker *workers, int count) {
char education[20];
printf("请输入要查询的学历:");
scanf("%s", education);
printf("职工信息如下:\n");
printf("职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t\t电话\n");
for (int i = 0; i < count; i++) {
if (strcmp(workers[i].education, education) == 0) {
printf("%s\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",
workers[i].id, workers[i].name, workers[i].sex, workers[i].age, workers[i].education, workers[i].salary, workers[i].address, workers[i].phone);
}
}
}
// 删除职工信息
void deleteWorker(Worker *workers, int *count) {
char name[20];
printf("请输入要删除的职工姓名:");
scanf("%s", name);
for (int i = 0; i < *count; i++) {
if (strcmp(workers[i].name, name) == 0) {
for (int j = i; j < *count - 1; j++) {
workers[j] = workers[j+1];
}
(*count)--;
printf("职工信息删除成功!\n");
return;
}
}
printf("未找到该职工信息!\n");
}
// 修改职工信息
void modifyWorker(Worker *workers, int count) {
for (int i = 0; i < count; i++) {
if (strcmp(workers[i].education, "研究生") == 0) {
workers[i].salary += 500;
}
}
printf("职工信息修改成功!\n");
}
int main() {
int choice = 0;
int count = 0;
Worker workers[MAX_WORKER_NUM];
while (1) {
menu();
scanf("%d", &choice);
switch (choice) {
case 1:
addWorker(workers, &count);
break;
case 2:
viewWorkers(workers, count);
break;
case 3:
printf("1. 按工号查询\n");
printf("2. 按学历查询\n");
printf("请输入数字选择查询方式:");
scanf("%d", &choice);
if (choice == 1) {
searchById(workers, count);
} else if (choice == 2) {
searchByEducation(workers, count);
} else {
printf("输入无效,请重新输入!\n");
}
break;
case 4:
deleteWorker(workers, &count);
break;
case 5:
modifyWorker(workers, count);
break;
case 6:
printf("谢谢使用!\n");
return 0;
default:
printf("输入无效,请重新输入!\n");
break;
}
}
return 0;
}
```
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)