要实现一个简单的职工信息管理系统,你可以使用C语言来编写以下功能:
struct Employee {
char name[50];
int id;
char position[50];
char department[50];
};
void addEmployee(struct Employee *employees, int *count) {
printf("Enter employee name: ");
scanf("%s", employees[*count].name);
printf("Enter employee ID: ");
scanf("%d", &employees[*count].id);
printf("Enter employee position: ");
scanf("%s", employees[*count].position);
printf("Enter employee department: ");
scanf("%s", employees[*count].department);
(*count)++;
}
void findEmployee(struct Employee *employees, int count) {
int id;
printf("Enter employee ID to search: ");
scanf("%d", &id);
for (int i = 0; i < count; i++) {
if (employees[i].id == id) {
printf("Employee Name: %s\n", employees[i].name);
printf("Employee Position: %s\n", employees[i].position);
printf("Employee Department: %s\n", employees[i].department);
return;
}
}
printf("Employee not found.\n");
}
void displayEmployees(struct Employee *employees, int count) {
for (int i = 0; i < count; i++) {
printf("Employee Name: %s\n", employees[i].name);
printf("Employee ID: %d\n", employees[i].id);
printf("Employee Position: %s\n", employees[i].position);
printf("Employee Department: %s\n", employees[i].department);
printf("\n");
}
}
以上是一个简单的职工信息管理系统的实现。你可以在主函数中调用这些函数来实现不同的操作,例如添加职工、查找职工和显示所有职工等。