Website Summary Files Commits Branches @commit @diff @stats
path: root / Week06 / Exercise09.cpp
diff options
context:
space:
mode:
1 files changed, 25 insertions, 0 deletions
-rw-r--r--Week06/Exercise09.cpp25
diff --git a/Week06/Exercise09.cpp b/Week06/Exercise09.cpp
new file mode 100644
index 0000000..80d126c
--- /dev/null
+++ b/Week06/Exercise09.cpp
@@ -0,0 +1,25 @@
+#include <iostream>
+
+int main() {
+ const unsigned int SIZE = 10;
+ int numbers[SIZE];
+
+ for (int i = 0; i < SIZE; i++)
+ std::cin >> numbers[i];
+
+ bool found = false;
+ for (int i = 0; i < SIZE && !found; i++) {
+ for (int j = i + 1; j < SIZE && !found; j++) {
+ for (int k = j + 1; k < SIZE && !found; k++) {
+ found = numbers[i] + numbers[j] + numbers[k] == 0;
+ }
+ }
+ }
+
+ if (found)
+ std::cout << "Exists" << std::endl;
+ else
+ std::cout << "Doesn't exist" << std::endl;
+
+ return 0;
+}