diff options
author | RossTheRoss <msattr@gmail.com> | 2019-02-19 19:35:00 -0600 |
---|---|---|
committer | RossTheRoss <msattr@gmail.com> | 2019-02-19 19:35:00 -0600 |
commit | 1660be41ca5a4f9b083dcf220d018a610749fd11 (patch) | |
tree | 104ebfbcf993fff57b51680b9c5526e6c7c90e2b /ee1301/wk2 | |
parent | E (diff) | |
download | homework-1660be41ca5a4f9b083dcf220d018a610749fd11.tar homework-1660be41ca5a4f9b083dcf220d018a610749fd11.tar.gz homework-1660be41ca5a4f9b083dcf220d018a610749fd11.tar.bz2 homework-1660be41ca5a4f9b083dcf220d018a610749fd11.tar.lz homework-1660be41ca5a4f9b083dcf220d018a610749fd11.tar.xz homework-1660be41ca5a4f9b083dcf220d018a610749fd11.tar.zst homework-1660be41ca5a4f9b083dcf220d018a610749fd11.zip |
F
Diffstat (limited to '')
-rw-r--r-- | ee1301/wk2/hw2_directory/strap012_2B.cpp | 67 |
1 files changed, 20 insertions, 47 deletions
diff --git a/ee1301/wk2/hw2_directory/strap012_2B.cpp b/ee1301/wk2/hw2_directory/strap012_2B.cpp index 862a0de..be727a3 100644 --- a/ee1301/wk2/hw2_directory/strap012_2B.cpp +++ b/ee1301/wk2/hw2_directory/strap012_2B.cpp @@ -14,77 +14,50 @@ 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): "; 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; - if (hourOG+hourChange>12) { - - } - 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 { - intervalChange = 12 - intervalChange; - if (intervalChange >= 13){ - intervalChange -= 12; - } - } - timeChange++; + hourNew=(hourOG+hourChange)-12; + bar=false; + } } - } 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') { |