From 6bb7b68394ebebbc69e76bee59e9351386115453 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 14 Dec 2025 21:56:30 +0200 Subject: feat(Week11): Add solutions --- Week11/Exercise05.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Week11/Exercise05.cpp (limited to 'Week11/Exercise05.cpp') 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 + +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; +} -- cgit v1.3.1-23-gd82d