aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301
diff options
context:
space:
mode:
Diffstat (limited to 'ee1301')
-rw-r--r--ee1301/wk2/hw2_directory/strap012_2B.cpp70
1 files changed, 20 insertions, 50 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_2B.cpp b/ee1301/wk2/hw2_directory/strap012_2B.cpp
index b5317bb..be727a3 100644
--- a/ee1301/wk2/hw2_directory/strap012_2B.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_2B.cpp
@@ -14,7 +14,7 @@ using namespace std;
int main()
{
- bool change12 = 0, foo = 0; //Workaround to prevent unneeded if statements
+ bool change12=0, foo=0, bar=true; //Workaround to prevent unneeded if statements
char Time, travel; //"time" is reserved by C++, "Time" is not
int hourOG, hourChange, hourNew, intervalChange = 0, timeChange = 1;
cout << "Enter current time (A for AM, P for PM): ";
@@ -23,71 +23,41 @@ int main()
cin >> hourChange >> travel;
for (int i = hourChange; i >= 0; i--)
{
- if (i != 0)
- {
- intervalChange++;
- }
- do
- {
- if (travel == 'B' && hourOG - intervalChange < 0)
- {
- if (hourChange < 12)
- {
- intervalChange -= 12;
+ if (travel=='F') {
+ if (hourOG+hourChange>=12 && bar) {
+ if (hourOG+hourChange==12) {
+ timeChange++;
+ } else {
+ hourNew=(hourOG+hourChange)-12;
+ bar=false;
}
- else
- {
- intervalChange = 12 - intervalChange;
- if (intervalChange >= 13)
- {
- intervalChange -= 12;
- }
- }
- timeChange++;
}
- } while (intervalChange > 12);
- if (intervalChange >= 12)
- {
- //if (intervalChange !=12) {i
- intervalChange = 0;
- timeChange++;
- //change12=1;
}
- }
+ if (travel=='B') {
- /* if (hourOG+hourChange>=12 || hourOG-hourChange<=0) {
- if (hourOG!=0 ^ hourOG!=12) {
- hourOG-=12;
}
- if (hourChange>12) {
- do {
- hourChange-=12;
- timeChange+=1;
- } while (hourChange >=11);
- }
- change12=1;
+ if (intervalChange >= 12) {
+ intervalChange = 0;
+ timeChange++;
+ }
}
-*/
- for (timeChange; timeChange > 1; timeChange--)
- {
+ for (timeChange; timeChange > 1; timeChange--) {
//if (change12) {
if (Time == 'A')
{
Time += 15;
- foo = true;
- }
- if (Time == 'P' && !foo)
- {
+ //foo = true;
+ } else {
+ if (Time == 'P') { //&& !foo) {
Time -= 15;
}
- foo = 0;
- //}
+ //foo = false;
+ }
}
-
if (travel == 'F')
{
- hourNew = hourOG + intervalChange;
+ //hourNew = hourOG + intervalChange;
}
if (travel == 'B')
{