Website Summary Files Commits Branches @commit @diff @stats
path: root / pract_SI / Pract. 05 / Solutions / task4.cpp
diff options
context:
space:
mode:
1 files changed, 23 insertions, 0 deletions
-rw-r--r--pract_SI/Pract. 05/Solutions/task4.cpp23
diff --git a/pract_SI/Pract. 05/Solutions/task4.cpp b/pract_SI/Pract. 05/Solutions/task4.cpp
new file mode 100644
index 0000000..19c1f38
--- /dev/null
+++ b/pract_SI/Pract. 05/Solutions/task4.cpp
@@ -0,0 +1,23 @@
+bool isPalindrom(int *arr, int size)
+{
+ for (int i = 0; i < size / 2; i++)
+ {
+ if (arr[i] != arr[size - i - 1])
+ return false;
+ }
+ return true;
+}
+
+bool isPalindrom(int number)
+{
+ int buffer[MAX_SIZE];
+ int size = 0;
+ while (number > 0) //1505
+ {
+ buffer[size] = number % 10; //5 0 5 1
+ number /= 10;
+ size++;
+ }
+
+ return isPalindrom(buffer, size);
+} \ No newline at end of file