I have a project where I have to schedule 3 doctors for 28 days. Doc A, B, and C.
The rules are:
1. They can't work back to back, but only on weekends. Example Doc. A can't work Monday and Tuesday, If Doc. A works Saturday, he must work Sunday also.
2. Doc. A and B work alternate weekends.
3. Doc. C can't work Tuesday or weekends.
There is more to the project but I'm not asking for that much help. I'm trying to base my project off of the 8 Queens program that uses backtracking and the goto function. Right now, I'm just trying to get my program to print this
100100100
010010010
001001001
Here is my goto Code
#include "stdafx.h"
#include <iostream>
#include<iostream>
using namespace std;
void print();
#define n 28
int a[n]={};
int b[n]={};
int c[n]={};
int x=0;
int main()
{
testA:
for(int i=0; i<n;i++) // check for consecutive days
{
if(a[i]==0)
{
a[i]=1;
i++;
}
else
a[i+1]=0;
}
testB:
for(int i=0; i<n;i++) // check for consecutive days
{
if(b[i]==0)
{
b[i]=1;
i++;
}
else
b[i+1]=0;
}
for(int i=0; i<n;i++) //checks to see if Docter B is working same shift with Docter A
{
if(b[i]==1 && a[i]==1)
{
b[i]=0;
b[i+1]=1;
}
}
testC:
for(int i=0; i<n;i++) // check for consecutive days
{
if(c[i]==0)
{
c[i]=1;
i++;
}
else
c[i+1]=0;
}
for(int i=0; i<n;i++) //checks to see if Docter C is working same shift with Doctor B and Doctor A
{
if((c[i]==1 && b[i]==1) || (c[i]==1 && a[i]==1))
{
c[i]=1;
c[i+1]=0;
}
}
goto print;
backtrack:
goto testA;
print:
for(int i=0; i<n;i++) //Prints line A
{
cout << a[i];
}
cout<<endl;
for(int i=0; i<n;i++) //Prints line B
{
cout << b[i];
}
cout<<endl;
for(int i=0; i<n;i++) //Prints line C
{
cout << c[i];
}
cout << endl;
return 0;
}
If you look at my code you will notice that it prints out like this, where array c doesn't take in account for array a.
1010101010101
0101010101010
1010101010101
I need some assistance on getting the program to modify a[], b[], and c[] when necessary. I should be able to change any array element to '1' and it will automatically fill in the schedule by itself. example
010001000101001
100100101010010
001010010000100
I am not asking for anyone to do my final project for me. Just asking for any useful tips.