Website Summary Files Commits Branches @commit @diff @stats
path: root / Week13 / Exercise17.cpp
diff options
context:
space:
mode:
Commit5c3b97fb2572ce8940439abd0652d2a7f7a623bd (patch)
Author
 Syndamia <kamen@syndamia.com>
2026-01-11 13:43:39 +0200
Committer
 Syndamia <kamen@syndamia.com>
2026-01-11 13:43:39 +0200
Filesc122f6fba2c8ac11ea022cc4b63fa89798994915 /Week13/Exercise17.cpp
upp-2025-solutions-5c3b97fb2572ce8940439abd0652d2a7f7a623bd.tar
upp-2025-solutions-5c3b97fb2572ce8940439abd0652d2a7f7a623bd.tar.gz
upp-2025-solutions-5c3b97fb2572ce8940439abd0652d2a7f7a623bd.zip
Parent3c427559e32750c40bbd0d95b525ea42e3b37fc7 (diff)
feat(Week13): Add solutions to most exercises
1 files changed, 25 insertions, 0 deletions
-rw-r--r--Week13/Exercise17.cpp25
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 <iostream>
+#include <cstring>
+
+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;
+}