From fc2f279a9344c31232275103c485d5c6335635ea Mon Sep 17 00:00:00 2001 From: Justsvetoslavov Date: Tue, 16 Nov 2021 16:56:56 +0200 Subject: Added solutions Pract.05 --- pract_SI/Pract. 05/Solutions/task4.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pract_SI/Pract. 05/Solutions/task4.cpp (limited to 'pract_SI/Pract. 05/Solutions/task4.cpp') 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 -- cgit v1.3.1-23-gd82d