CS计算机代考程序代写 #include

#include
#include
#include “refcount.h”

/** MODULE Job */

struct Job {
int data;
int num;
};

int number = 0;

struct Job *create_job(int d) {
struct Job *j = malloc(sizeof(*j));
j->num = ++number;
j->data = d;
return j;
}

struct Job *pendingJob = NULL;

void start_job(struct Job *j) {
if (pendingJob) {
printf(“**Completing job: #%d**\n”, pendingJob->num);
pendingJob = NULL;
}
if (j) {
if (j->data % 3 == 0) {
printf(“**Starting job: #%d**\n”, j->num);
pendingJob = j;
} else {
printf(“**Skipped job #%d**\n”, j->num);
j-> data = 0;
}
}
}

/** MODULE Organize */

int organizeJob(int d) {
struct Job *j = create_job(d);
start_job(j);
return j->data;
}

void finishForTheDay() {
start_job(NULL);
}

/** MODULE Main */

int main() {
printf(“Starting to review job data\n”);
int work_started = 0;
work_started += organizeJob(7);
work_started += organizeJob(3);
work_started += organizeJob(12);
work_started += organizeJob(5);
work_started += organizeJob(15);
finishForTheDay();
printf(“Total work started: %d\n”, work_started);
}