资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

2人一天排班java代码的简单介绍

用java实现7个人值班,每人值班一周,从周一到周日,轮流值班

7个人值班,每人值班一周

创新互联是一家专注于做网站、网站制作与策划设计,高平网站建设哪家好?创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:高平等地区。高平做网站价格咨询:18982081108

从周一到周日,轮流值班

需求不清楚,到底是每人值一天,还是每人值一周?

如果是每人值一天,一周七天,七人轮流,那就不需要算法了.

怎么用c语言编制一个12人排班,一天2人,一星期中每人只能休息一天。每个员工可以预先自行选择一个天

#include stdio.h

#include stdlib.h

int sum = 0;

void restSort(int* staffs_ptr,int staff_size,int* rest_staffs_ptr,int rest_staff_size);

void print(int* rest_ptr, int rest_size);

int main() {

int init_size = 12;

int *staffs_ptr = (int*)malloc(sizeof(int) * init_size);

if (staffs_ptr != NULL) {

for (int i = 0; i init_size; i++) {

*(staffs_ptr + i) = i + 1;

}

restSort(staffs_ptr,init_size,NULL,0);

free(staffs_ptr);

printf("sum = %d\n",sum);

}

return 0;

}

void restSort(int* staffs_ptr, int staff_size, int* rest_staffs_ptr, int rest_staff_size) {

if (staff_size = 2) {

if (rest_staffs_ptr != NULL rest_staff_size 0) {

int yet_rest_staff_size = rest_staff_size + staff_size;

int* yet_rest_staffs_ptr = (int*)malloc(sizeof(int) * yet_rest_staff_size);

if (yet_rest_staffs_ptr != NULL) {

for (int rest_index = 0; rest_index rest_staff_size; rest_index++) {

yet_rest_staffs_ptr[rest_index] = rest_staffs_ptr[rest_index];

}

for (int index = rest_staff_size; index yet_rest_staff_size; index++) {

yet_rest_staffs_ptr[index] = staffs_ptr[index - rest_staff_size];

}

print(yet_rest_staffs_ptr,yet_rest_staff_size);

free(yet_rest_staffs_ptr);

}

}

else {

print(staffs_ptr,staff_size);

}

return;

}

for (int i = 0; i staff_size - 1; i++) {

for (int j = i + 1; j staff_size; j++) {

int* residue_staff_ptr = (int*)malloc(sizeof(int) * (staff_size - 2));

if (residue_staff_ptr != NULL) {

int residue_size = 0;

for (int index = 0; index staff_size; index++) {

if (index == i || index == j)

continue;

residue_staff_ptr[residue_size] = staffs_ptr[index];

residue_size++;

}

int yet_rest_staff_size = rest_staff_size + 2;

int* yet_rest_staffs_ptr = (int*)malloc(sizeof(int) * yet_rest_staff_size);

if (yet_rest_staffs_ptr != NULL) {

if (rest_staffs_ptr != NULL rest_staff_size 0) {

for (int rest_index = 0; rest_index rest_staff_size; rest_index++) {

yet_rest_staffs_ptr[rest_index] = rest_staffs_ptr[rest_index];

}

}

yet_rest_staffs_ptr[rest_staff_size] = staffs_ptr[i];

yet_rest_staffs_ptr[rest_staff_size + 1] = staffs_ptr[j];

restSort(residue_staff_ptr, residue_size,yet_rest_staffs_ptr,yet_rest_staff_size);

free(yet_rest_staffs_ptr);

}

free(residue_staff_ptr);

}

}

}

}

void print(int* rest_ptr, int rest_size) {

for (int i = 1; i = 7; i++) {

int day = 1;

for (int j = 0; j rest_size;) {

if (day == i) {

printf("星期 %d: 无 ",day);

}

else {

printf("星期 %d: %d ",day,rest_ptr[j]);

j++;

if (j rest_size) {

printf("%d ", rest_ptr[j]);

j++;

}

}

day++;

}

if (day == 7) {

printf("星期 7: 无");

}

printf("\n");

sum++;

}

}

三人上班每天2人 排班

假如这样排列你们的时刻表 17AB 18BC 19AC 20AB 21BC 22AC 23AB 24BC

18号假如刚好你休假 19号就要跟21号的B换 20号就要跟24号的C换班

但是换之前和换之后你都要连续工作好几天

如何用java实现人员自动排班的问题

应该用不上什么线程,一次性把所有的班都排好

六个元素的数组

两个指针,一个是工作日当值人,一个是周末当值人,初始都是0

从今天开始到指定某一天,譬如年底

int idx_workday =0;

int idx_weekend =0;

ArrayList assignment = new ArrayList();

day = today;

while(day不是年底){

int i;

if (day is workday){

i = idx_workday++;

assignment.add(i);

if (idx_workday 5) idx_workday = 0;

}else{

i = idx_weekend++;

assignment.add(i);

if (idx_weekend 5) idx_weekend= 0;

}

}

output assignment


本文题目:2人一天排班java代码的简单介绍
网页URL:http://cdkjz.cn/article/hcpgpc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220