Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
| declarations | function calls |
struct Room
{
string bldg;
string rmnum;
string type;
double sqft;
};
ifstream fin;
Room R;
int N;
Room *B; |
read(R,fin); if (isDoubleOccOffice(R)) swap(B[N-1],R); write(B,N,cout); |
~/$ ./prog : meets W4 HE112 4001 MWF4 HE112 9001 WF9 SC112 4000 TRF4,W34 SC112 4040 M4,WF4,T56 SC112 5534 MTR5,W34 : meets F6 : meets T1 EE301 1111 M1,TR12 SC112 8812 TR8,W12 SC112 8012 TR8,F12 : quitTo make your like easier, I am gifting you the following function (read the documentation about what the function does for you very carefully but don't bother trying to understand how the function works!):
/**************************************************************************************
Input: pat - a string representing a meeting time, e.g. "MWF2,R34" or "TR9" or "MF5,T65"
day - a char, one of M,T,W,R,F
per - an int, one of the regular periods, i.e. 1,2,3,4,5,6 (no 8,9,10 allowed!)
Output:true if the meeting time in pattern pat overlaps with period day,per, false otherwise
Ex1 - overlaps("MWF2,R12",'M',8) -> true overlaps("TR10",'T',4) -> false
**************************************************************************************/
bool overlaps(string pat, char day, int per)
{
bool dflag = false; // day match flag
for(int i = 0; i < pat.length(); i++)
{
if (pat[i] == ',')
dflag = false;
else if ('A' <= pat[i] && pat[i] <= 'Z')
dflag = dflag || pat[i] == day;
else
{
int q = pat[i] == '1' && i+1 < pat.length() && pat[i+1] == '0' ? 10 : (pat[i] - '0');
if (dflag && (per == q || (per-1)/2 + 8 == q))
return true;
}
}
return false;
}