Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cctype>
- #include <iostream>
- #include <string>
- template <typename variable>
- bool palindromeCheck(variable word) // Function that finds not equal letter in word and return false, else - true
- {
- for (int i = 0; i < word.length()/2; i++) {
- if (std::tolower(word[i]) != std::tolower(word[word.length() - 1 - i])) {
- return false;
- }
- }
- return true;
- }
- int main(int argc, char *argv[])
- {
- std::cout << "Введите слово для проверки, является ли оно палиндромом (ENG only): ";
- std::string palindrome;
- std::getline(std::cin, palindrome);
- palindromeCheck(palindrome)? std::cout << "Your word is palindrome": std::cout << "Your word isn't palindrome";
- std::cout << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment