Website Summary Files Commits Branches @commit @diff @stats
path: root / Week11 / Exercise05.cpp
diff options
context:
space:
mode:
Commit6bb7b68394ebebbc69e76bee59e9351386115453 (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-12-14 21:56:30 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-12-14 21:56:30 +0200
Filesc31eb47780b5bfe4d038b6d6b8f32a385d717b96 /Week11/Exercise05.cpp
upp-2025-solutions-6bb7b68394ebebbc69e76bee59e9351386115453.tar
upp-2025-solutions-6bb7b68394ebebbc69e76bee59e9351386115453.tar.gz
upp-2025-solutions-6bb7b68394ebebbc69e76bee59e9351386115453.zip
Parent5ce214686e668bf185222b518b78d7f47a20b4fd (diff)
feat(Week11): Add solutions
1 files changed, 28 insertions, 0 deletions
-rw-r--r--Week11/Exercise05.cpp28
diff --git a/Week11/Exercise05.cpp b/Week11/Exercise05.cpp
new file mode 100644
index 0000000..5177003
--- /dev/null
+++ b/Week11/Exercise05.cpp
@@ -0,0 +1,28 @@
+#include <iostream>
+
+int main() {
+ const unsigned SIZE = 1024;
+
+ char str[SIZE];
+ std::cin.getline(str, SIZE, ':');
+ double a, b;
+ std::cin >> a >> b;
+
+ for (unsigned i = 0; str[i] != '\0' && str[i+2] != '\0'; i++) {
+ if (str[i] == 's' &&
+ str[i+1] == 'u' &&
+ str[i+2] == 'm')
+ {
+ std::cout << (a + b) << ' ';
+ }
+ else if (str[i] == 's' &&
+ str[i+1] == 'u' &&
+ str[i+2] == 'b')
+ {
+ std::cout << (a - b) << ' ';
+ }
+ }
+ std::cout << std::endl;
+
+ return 0;
+}