Website Summary Files Commits Branches @commit @diff @stats
path: root / Week05 / Exercise08.cpp
diff options
context:
space:
mode:
1 files changed, 32 insertions, 0 deletions
-rw-r--r--Week05/Exercise08.cpp32
diff --git a/Week05/Exercise08.cpp b/Week05/Exercise08.cpp
new file mode 100644
index 0000000..47fa376
--- /dev/null
+++ b/Week05/Exercise08.cpp
@@ -0,0 +1,32 @@
+#include <iostream>
+
+int main() {
+ const unsigned int SIZE = 10;
+
+ /* Става по-елегантно ако използваме един масив */
+ double row1[SIZE], row2[SIZE];
+ for (int i = 0; i < SIZE; i++) {
+ std::cin >> row1[i];
+ }
+ for (int i = 0; i < SIZE; i++) {
+ std::cin >> row2[i];
+ }
+
+ char operation;
+ std::cin >> operation;
+
+ double result;
+ for (int i = 0; i < SIZE; i++) {
+ switch (operation) {
+ case '+': result = row1[i] + row2[i]; break;
+ case '-': result = row1[i] - row2[i]; break;
+ case '*': result = row1[i] * row2[i]; break;
+ case '/': result = row1[i] / row2[i]; break;
+ }
+ std::cout << result << ' ';
+ }
+
+ std::cout << std::endl;
+
+ return 0;
+}