用c语言写个排班表系统

编写一个排班表系统需要考虑到很多因素,例如员工的班次、休息日、节假日等。以下是一个简单的排班表系统的示例代码,仅供参考:

#include <stdio.h>  
#include <string.h>  
  
#define MAX_EMPLOYEES 100  
#define MAX_NAME_LENGTH 50  
#define MAX_SHIFT_LENGTH 10  
  
typedef struct {  
    char name[MAX_NAME_LENGTH];  
    char shift[MAX_SHIFT_LENGTH];  
    int workdays[5]; // Monday to Friday  
} Employee;  
  
void print_schedule(Employee employees[], int num_employees) {  
    for (int i = 0; i < num_employees; i++) {  
        printf("%s\t%s\t", employees[i].name, employees[i].shift);  
        for (int j = 0; j < 5; j++) {  
            if (employees[i].workdays[j] == 1) {  
                printf("%s ", (j == 4) ? "Weekend" : "Mon");  
            } else {  
                printf("- ");  
            }  
        }  
        printf("\n");  
    }  
}  
  
int main() {  
    Employee employees[MAX_EMPLOYEES];  
    int num_employees;  
    printf("Enter the number of employees: ");  
    scanf("%d", &num_employees);  
    for (int i = 0; i < num_employees; i++) {  
        printf("Enter name of employee %d: ", i + 1);  
        scanf("%s", employees[i].name);  
        printf("Enter shift of employee %d: ", i + 1);  
        scanf("%s", employees[i].shift);  
        for (int j = 0; j < 5; j++) {  
            printf("Enter workdays for employee %d (1 for workday, 0 for non-workday): ", i + 1);  
            scanf("%d", &employees[i].workdays[j]);  
        }  
    }  
    print_schedule(employees, num_employees);  
    return 0;  
}

该程序首先定义了一个 Employee 结构体,用于存储员工的姓名、班次和每周的工作日。然后,程序通过 print_schedule 函数打印出排班表。在 main 函数中,程序首先要求用户输入员工的数量,然后依次输入每个员工的姓名、班次和每周的工作日。最后,程序调用 print_schedule 函数打印出排班表。

  • 14
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值