Website Summary Files Commits Branches @commit @diff @stats
path: root / Week06 / Exercise08.cpp
diff options
context:
space:
mode:
Commitec8ecd4dc19854007428761c330303854478201f (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-11-06 19:13:54 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-11-06 19:15:07 +0200
Files662f55a328b60a70273a5e6fc564b1511da906cf /Week06/Exercise08.cpp
upp-2025-solutions-ec8ecd4dc19854007428761c330303854478201f.tar
upp-2025-solutions-ec8ecd4dc19854007428761c330303854478201f.tar.gz
upp-2025-solutions-ec8ecd4dc19854007428761c330303854478201f.zip
Parent9242ebc4c69f2c1f550ddcc0e9235f3f409554c7 (diff)
feat(Week06): Add exercises and solutions
1 files changed, 30 insertions, 0 deletions
-rw-r--r--Week06/Exercise08.cpp30
diff --git a/Week06/Exercise08.cpp b/Week06/Exercise08.cpp
new file mode 100644
index 0000000..d9fced9
--- /dev/null
+++ b/Week06/Exercise08.cpp
@@ -0,0 +1,30 @@
+#include <iostream>
+
+int main() {
+ const double PI = 3.14159;
+
+ double x, y;
+ std::cin >> x >> y;
+
+ /* Уравнение на окръжността:
+ * (x - a) ^^ 2 + (y - b) ^^ 2 = r ^^ 2
+ * където ^^ представлява операцията степенуване (само за обяснението, няма такава в C++),
+ * a и b са координати на центъра на окръжността,
+ * r е радиуса на окръжността.
+ *
+ * Очевидно, ако имаме <, тогава сме в кръга, и ако имаме >, сме извън.
+ */
+
+ const double BLUE_X = 1, BLUE_Y = 0, BLUE_R = 3;
+ bool inside_blue = (x - BLUE_X) * (x - BLUE_X) + (y - BLUE_Y) * (y - BLUE_Y) < BLUE_R * BLUE_R;
+
+ const double RED_X = 0, RED_Y = -1, RED_R = 3;
+ bool outside_red = (x - RED_X) * (x - RED_X) + (y - RED_Y) * (y - RED_Y) > RED_R * RED_R;
+
+ if (inside_blue && outside_red)
+ std::cout << "Inside" << std::endl;
+ else
+ std::cout << "Outside" << std::endl;
+
+ return 0;
+}