Commit 95bdb431 authored by Michael's avatar Michael

michael.davityan:exercise_07_32v2

parent 416d58a9
......@@ -2,7 +2,7 @@ progname=exercise_07_32
CC=g++
CFLAGS=-Wall -Wextra -Werror -g3
all: test1 test2
all: test1 test2 test3 test4
debug/$(progname): debug/$(progname).o
$(CC) $(CFLAGS) $< -o $@
......
......@@ -7,12 +7,11 @@ palindromeCheck(const std::string word, int sizeOfWord, int firstLetterIndex = 0
{
if (firstLetterIndex == sizeOfWord) {
return true;
} else {
if (word[firstLetterIndex] != word[sizeOfWord]) {
return false;
}
return palindromeCheck(word, sizeOfWord - 1, firstLetterIndex + 1);
}
if (word[firstLetterIndex] != word[sizeOfWord]) {
return false;
}
return palindromeCheck(word, sizeOfWord - 1, firstLetterIndex + 1);
}
int
......@@ -26,10 +25,7 @@ main()
}
std::string word;
std::cin >> word;
int sizeOfWord = 0;
for (size_t index = 0; word[index] != '\0'; ++index) {
++sizeOfWord;
}
int sizeOfWord = word.size();
std::cout << palindromeCheck(word, sizeOfWord - 1) << std::endl;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment