人事管理系统 C语言,人事管理系统----C语言设计
时间: 2023-09-19 15:09:22 浏览: 47
人事管理系统是一个管理企业员工信息的软件,主要用于实现员工信息的录入、查询、修改和删除等功能。下面是一个简单的人事管理系统的C语言设计示例。
1. 数据结构设计
在设计人事管理系统时,我们需要定义员工信息的数据结构。这个数据结构应该包含员工的基本信息,如姓名、性别、出生日期、联系方式、职位等。
```
typedef struct employee {
char name[20];
char gender[10];
char birthdate[20];
char phone[20];
char position[20];
float salary;
} Employee;
```
2. 功能模块设计
人事管理系统的主要功能包括:
- 员工信息的录入
- 员工信息的查询
- 员工信息的修改
- 员工信息的删除
下面是一个简单的C语言程序,实现了以上四个功能模块。
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_EMPLOYEES 100
typedef struct employee {
char name[20];
char gender[10];
char birthdate[20];
char phone[20];
char position[20];
float salary;
} Employee;
Employee employees[MAX_EMPLOYEES];
int numEmployees = 0;
void addEmployee() {
if (numEmployees == MAX_EMPLOYEES) {
printf("Too many employees, can't add more.\n");
return;
}
Employee newEmployee;
printf("Enter the employee's name: ");
scanf("%s", newEmployee.name);
printf("Enter the employee's gender: ");
scanf("%s", newEmployee.gender);
printf("Enter the employee's birthdate: ");
scanf("%s", newEmployee.birthdate);
printf("Enter the employee's phone number: ");
scanf("%s", newEmployee.phone);
printf("Enter the employee's position: ");
scanf("%s", newEmployee.position);
printf("Enter the employee's salary: ");
scanf("%f", &newEmployee.salary);
employees[numEmployees] = newEmployee;
numEmployees++;
printf("Employee added successfully.\n");
}
void searchEmployee() {
char name[20];
printf("Enter the employee's name: ");
scanf("%s", name);
int found = 0;
printf("Search results:\n");
for (int i = 0; i < numEmployees; i++) {
if (strcmp(name, employees[i].name) == 0) {
printf("Name: %s\n", employees[i].name);
printf("Gender: %s\n", employees[i].gender);
printf("Birthdate: %s\n", employees[i].birthdate);
printf("Phone number: %s\n", employees[i].phone);
printf("Position: %s\n", employees[i].position);
printf("Salary: %.2f\n", employees[i].salary);
found = 1;
break;
}
}
if (!found) {
printf("No employee found with the name %s.\n", name);
}
}
void updateEmployee() {
char name[20];
printf("Enter the employee's name: ");
scanf("%s", name);
int found = 0;
for (int i = 0; i < numEmployees; i++) {
if (strcmp(name, employees[i].name) == 0) {
printf("Enter the new information for the employee:\n");
printf("Gender: ");
scanf("%s", employees[i].gender);
printf("Birthdate: ");
scanf("%s", employees[i].birthdate);
printf("Phone number: ");
scanf("%s", employees[i].phone);
printf("Position: ");
scanf("%s", employees[i].position);
printf("Salary: ");
scanf("%f", &employees[i].salary);
found = 1;
printf("Employee updated successfully.\n");
break;
}
}
if (!found) {
printf("No employee found with the name %s.\n", name);
}
}
void deleteEmployee() {
char name[20];
printf("Enter the employee's name: ");
scanf("%s", name);
int found = 0;
for (int i = 0; i < numEmployees; i++) {
if (strcmp(name, employees[i].name) == 0) {
for (int j = i; j < numEmployees - 1; j++) {
employees[j] = employees[j + 1];
}
numEmployees--;
found = 1;
printf("Employee deleted successfully.\n");
break;
}
}
if (!found) {
printf("No employee found with the name %s.\n", name);
}
}
int main() {
int choice;
while (1) {
printf("1. Add employee\n");
printf("2. Search employee\n");
printf("3. Update employee\n");
printf("4. Delete employee\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
addEmployee();
break;
case 2:
searchEmployee();
break;
case 3:
updateEmployee();
break;
case 4:
deleteEmployee();
break;
case 5:
exit(0);
default:
printf("Invalid choice, please try again.\n");
break;
}
}
return 0;
}
```
以上是一个简单的人事管理系统的C语言设计示例,仅供参考。实际应用中,需要根据具体需求进行进一步设计和开发。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)