-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe14.cpp
72 lines (63 loc) · 1.05 KB
/
e14.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "../std_lib_facilities.h"
// Tuesday 23 Friday 56 Tuesday -3 Thursday 99
int main ()
{
vector<int> day_of_the_week (7);
string s;
int value;
cout << "Enter (day-of-the-week, value) pairs (p to print and q to quit): " << endl;
while (true)
{
cin >> s;
for (auto &c: s)
{
c = char(tolower(c));
}
if (s.front() == 'q')
{
exit(EXIT_SUCCESS);
}
else if (s.front() == 'p')
{
for (int i = 0 ; i < day_of_the_week.size(); ++i)
{
cout << "day " << i + 1 << "\t\t" << day_of_the_week[i] << endl;
}
continue;
}
s.resize(3);
cin >> value;
if (s == "mon")
{
day_of_the_week[0] += value;
}
else if (s == "tue")
{
day_of_the_week[1] += value;
}
else if (s == "wed")
{
day_of_the_week[2] += value;
}
else if (s == "thu")
{
day_of_the_week[3] += value;
}
else if (s == "fri")
{
day_of_the_week[4] += value;
}
else if (s == "sat")
{
day_of_the_week[5] += value;
}
else if (s == "sun")
{
day_of_the_week[6] += value;
}
else
{
cout << "rejecting: " << s << ", " << value << endl;
}
}
}