Home > Back-end >  The algorithm on duty
The algorithm on duty

Time:09-16

Seven people on duty schedule for each week a, b, c, d, e, f, g
Among them 1, a, b on duty only 4 times every month
2, 7 individual polling on duty, for example, on duty this week order for abcdeg should be bcdefga next week, next week is again cdefgab
3, the required input data for years, the output is according to the calendar layout table,

CodePudding user response:

Cycle are 7 in a row for a year, month by month) is in line with the requirements,

CodePudding user response:

The depth of search algorithm is used,

CodePudding user response:

Write a small program test, it is no solution, may I understand is wrong, the problem of the building Lord

CodePudding user response:

Is this your scheduling algorithm, a bit complicated,,,,

CodePudding user response:

Remember long ago exposed programming program is a print lists, this small program, and then put on Monday to Sunday as a - g, a judge on Monday and Tuesday are added into the loop, if in the same month accumulative total to 4 times, jump in the past began to implement the pulmonary circulation, circulation, namely Wednesday in judgment, until a month increases, the count,

CodePudding user response:

2 according to the requirement of the building Lord, a and b on duty date is not fixed Monday and Tuesday, is a cycle, namely abcdefg 49 days everyone on Monday to Sunday on duty each day,

CodePudding user response:

Feel no problem, "a, b each month on duty only four times", the cycle of a, b, respectively, count to four times a week, and month number unchanged, after deducting a or b according to the number of remaining continue to cycle, if months increased, will reset all continue to cycle,
Logic judgment too much trouble, too lazy to write the code,

CodePudding user response:

Cycle of a and b respectively count to four times a week, and month number unchanged, after deducting a or b according to the number of remaining continue to cycle, if months increased, all is reset to the rest of the cycle, to the last G, plus a or b,
Really too much trouble, jumping,

CodePudding user response:

A look at the AB is a special character privileged,

CodePudding user response:

refer to the eighth floor leavesguth response:
loop. A, b, respectively, count to four times a week, and months unchanged, after deducting a or b according to the number of remaining continue to cycle, if months increased, all is reset to the rest of the cycle, to the last G, plus a or b,
Really too much trouble, jumping,


7 individual polling on duty, for example, on duty this week order for abcdeg should be bcdefga next week, next week is again cdefgab

CodePudding user response:

Can, in turn, looking for ah, directly according to the first 1234567234671,... Print the calendar again this way, then from 1 to 7, in turn, find every two months at most only four elements (for example, to find out is 3, and 5), and specify 3=a, 5=b, and other elements randomly assigned,
  • Related