diff options
author | RossTheRoss <msattr@gmail.com> | 2019-02-20 17:44:09 +0000 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-02-20 17:44:09 +0000 |
commit | 01d703f452715af5b190efe319d471d80b7bd70d (patch) | |
tree | 4ead89476a5536faebb18ffb26fe470812dbf731 /ee1301/wk2 | |
parent | Fix things, start lab (diff) | |
download | homework-01d703f452715af5b190efe319d471d80b7bd70d.tar homework-01d703f452715af5b190efe319d471d80b7bd70d.tar.gz homework-01d703f452715af5b190efe319d471d80b7bd70d.tar.bz2 homework-01d703f452715af5b190efe319d471d80b7bd70d.tar.lz homework-01d703f452715af5b190efe319d471d80b7bd70d.tar.xz homework-01d703f452715af5b190efe319d471d80b7bd70d.tar.zst homework-01d703f452715af5b190efe319d471d80b7bd70d.zip |
FINISH 2B FINALLY
Diffstat (limited to 'ee1301/wk2')
-rw-r--r-- | ee1301/wk2/hw2_directory/strap012_HW2B.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_HW2B.cpp b/ee1301/wk2/hw2_directory/strap012_HW2B.cpp index 113186b..ee92ff9 100644 --- a/ee1301/wk2/hw2_directory/strap012_HW2B.cpp +++ b/ee1301/wk2/hw2_directory/strap012_HW2B.cpp @@ -20,7 +20,7 @@ int main() cout << "Enter current time (A for AM, P for PM): "; cin >> hourOG >> Time; cout << "How many hours forward or backward do you want to move the clock (F for forwards, B for backward): "; - cin >> hourChange >> travel; + cin >> travel >> hourChange; for (int i = hourChange; i >= 0; i--) { if (i != 0) @@ -51,6 +51,23 @@ int main() if (travel == 'B') { + if (hourOG - hourChange <= 0) + { + int temp = (hourOG - hourChange) + 12; + bar=true; + while (temp>12) { + temp-=12; + timeChange++; + } + if (hourChange<=24) { + hourNew=temp; + } else { + for (int k=(hourChange%24); k>0; k--) { + hourNew=temp+12; + } + } + } + timeChange++; } if (intervalChange >= 12) { @@ -68,7 +85,7 @@ int main() { if (Time == 'P') { - Time -= 15; //See line 64 + Time -= 15; } } } @@ -76,7 +93,7 @@ int main() { hourNew = hourOG + intervalChange; } - if (travel == 'B') + if (travel == 'B' && !bar) { hourNew = hourOG - intervalChange; } |