From 5c3b97fb2572ce8940439abd0652d2a7f7a623bd Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 11 Jan 2026 13:43:39 +0200 Subject: feat(Week13): Add solutions to most exercises --- Week13/Exercise17.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Week13/Exercise17.cpp (limited to 'Week13/Exercise17.cpp') diff --git a/Week13/Exercise17.cpp b/Week13/Exercise17.cpp new file mode 100644 index 0000000..952143f --- /dev/null +++ b/Week13/Exercise17.cpp @@ -0,0 +1,25 @@ +#include +#include + +bool isPalindrome(unsigned left, unsigned right, const char* str) { + if (left >= right) + return true; + else if (str[left] != str[right]) + return false; + else + return isPalindrome(left + 1, right - 1, str); +} + +int main() { + const unsigned LINE_LEN = 1024; + + char line[LINE_LEN]; + std::cin.getline(line, LINE_LEN); + + if (isPalindrome(0, strlen(line) - 1, line)) + std::cout << "Is a palindrome" << std::endl; + else + std::cout << "Not a palindrome" << std::endl; + + return 0; +} -- cgit v1.3.1-23-gd82d