用c++写一个排班系统
时间: 2023-05-19 11:03:22 浏览: 135
好的,我可以为您提供一个基本的排班系统的代码示例:
```c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_EMPLOYEES 100
#define MAX_DAYS 31
typedef struct {
char name[50];
int days[MAX_DAYS];
} Employee;
int main() {
Employee employees[MAX_EMPLOYEES];
int numEmployees, numDays;
printf("Enter the number of employees: ");
scanf("%d", &numEmployees);
printf("Enter the number of days in the month: ");
scanf("%d", &numDays);
for (int i = 0; i < numEmployees; i++) {
printf("Enter the name of employee %d: ", i+1);
scanf("%s", employees[i].name);
for (int j = 0; j < numDays; j++) {
printf("Enter 1 if %s is working on day %d, 0 otherwise: ", employees[i].name, j+1);
scanf("%d", &employees[i].days[j]);
}
}
printf("Employee Schedule:\n");
for (int i = 0; i < numEmployees; i++) {
printf("%s: ", employees[i].name);
for (int j = 0; j < numDays; j++) {
printf("%d ", employees[i].days[j]);
}
printf("\n");
}
return 0;
}
```
这个程序可以让您输入员工的姓名和每个员工在每天是否工作的信息,并输出一个员工排班表。您可以根据需要进行修改和扩展。
阅读全文