From 3e8ac7ba4a8f410703aa5a8426f542217adcbf2f Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 14 Nov 2025 20:55:42 +0200 Subject: feat(Week07): Add solutions --- Week07/Exercise13.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Week07/Exercise13.cpp (limited to 'Week07/Exercise13.cpp') diff --git a/Week07/Exercise13.cpp b/Week07/Exercise13.cpp new file mode 100644 index 0000000..95115f9 --- /dev/null +++ b/Week07/Exercise13.cpp @@ -0,0 +1,30 @@ +#include + +bool isDigit(char x) { + return '0' <= x && x <= '9'; +} + +bool isLetter(char x) { + return ('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'); +} + +bool followsPattern(char letters[4]) { + return isLetter(letters[0]) && isDigit(letters[1]) && isLetter(letters[2]) && isDigit(letters[3]); +} + +int main() { + const unsigned int SIZE = 12; + char input[SIZE]; + for (unsigned int i = 0; i < SIZE; i++) + std::cin >> input[i]; + + for (unsigned int i = 0; i < SIZE; i += 4) { + if (!followsPattern(input)) { + std::cout << "Does not follow pattern" << std::endl; + return 0; + } + } + + std::cout << "Follows pattern" << std::endl; + return 0; +} -- cgit v1.3.1-23-gd82d