- 论坛徽章:
- 0
|
A worker needs to do A work and B work. B's priority is higher than A. For example, if he shall do A from 9:00 to 13:00, and shall doing B from 10:00 to 11:00, his choice shall be doing A from 9:00 to 10:00, doing B from 10:00 to 11:00, and doing A from 11:00 to 13:00.
Complete the following function, ”pSchedule“ is a worker's work schedule (it's an array), "nNum" is number of elements in array "pSchedule", "ppResult" is the result array which shall be returned, "nRNum" is number of elements in “ppResult". The time phases in "pSchedule" cover each other, and not sorted, the output data in "ppResult" shall be a new schedule that are not covered of any phase, and sorted by start time. Return 0 if success.
You can add sub-functions and use C standard functions.enum WORK
{
A, // A work
B // B work
};
struct SCHED
{
int nStartHour; // at that hour work start
int nEndHour; // at that hour work end
enum WORK work; // work type
};
int func(const struct SCHED* pSchedule, unsigned int nNum, struct SCHED** ppResult, unsigned int& nRNum)
{
} |
|
|