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