aboutsummaryrefslogtreecommitdiff
path: root/week02/exercise10.cpp
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2023-10-19 19:40:08 +0300
committerSyndamia <kamen@syndamia.com>2023-10-19 19:40:08 +0300
commitfbbe586d25b1ebaf66fe2e92e1986bb5debf961d (patch)
tree58f288b71fd5d1e046158b442438ea282285a619 /week02/exercise10.cpp
parenta597f37a109398549d8ab098a2d6de19a4a1b4b8 (diff)
downloadupp-2023-solutions-fbbe586d25b1ebaf66fe2e92e1986bb5debf961d.tar
upp-2023-solutions-fbbe586d25b1ebaf66fe2e92e1986bb5debf961d.tar.gz
upp-2023-solutions-fbbe586d25b1ebaf66fe2e92e1986bb5debf961d.zip
[w2] Added solutions
Diffstat (limited to 'week02/exercise10.cpp')
-rw-r--r--week02/exercise10.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/week02/exercise10.cpp b/week02/exercise10.cpp
new file mode 100644
index 0000000..434aaa0
--- /dev/null
+++ b/week02/exercise10.cpp
@@ -0,0 +1,21 @@
+#include <iostream>
+
+int main() {
+ int signals;
+ std::cin >> signals;
+
+ int leftSignal = signals / 1000;
+ int rightSignal = signals % 1000;
+
+ // difference е дефакто абсолютната стойност на leftSignal - rightSignal
+ int difference = leftSignal - rightSignal;
+ if (difference < 0)
+ difference *= -1;
+
+ if (difference <= 3)
+ std::cout << "Follow heading" << std::endl;
+ else if (leftSignal < rightSignal)
+ std::cout << "Turn left" << std::endl;
+ else
+ std::cout << "Turn right" << std::endl;
+}