aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk2
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ee1301/wk2/hw2_directory/strap012_2B.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_2B.cpp b/ee1301/wk2/hw2_directory/strap012_2B.cpp
index b07028a..2a600b4 100644
--- a/ee1301/wk2/hw2_directory/strap012_2B.cpp
+++ b/ee1301/wk2/hw2_directory/strap012_2B.cpp
@@ -25,10 +25,15 @@ int main () {
intervalChange++;
} do {
if (travel=='B' && hourOG-intervalChange<0){
- if (hourChange<12)
- intervalChange=12-hourChange;
- else
- intervalChange=hourChange-12;
+ if (hourChange<12) {
+ intervalChange-=12;
+ } else {
+ intervalChange=12-intervalChange;
+ if (intervalChange>=13) {
+ intervalChange-=12;
+ }
+ }
+ timeChange++;
}
} while (intervalChange>12);
if (intervalChange>=12) {