要實現一個簡單的職工信息管理系統,你可以使用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");
}
}
以上是一個簡單的職工信息管理系統的實現。你可以在主函數中調用這些函數來實現不同的操作,例如添加職工、查找職工和顯示所有職工等。