1 /**********************************************************************
3 * Description: Application for finding anagrams of a word
4 * Author: Agnibho Mondal
5 * Website: http://code.agnibho.com/anagram
6 **********************************************************************
7 Copyright (c) 2013-2015 Agnibho Mondal
9 **********************************************************************
10 This file is part of Anagram.
12 Anagram is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
17 Anagram is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with Anagram. If not, see <http://www.gnu.org/licenses/>.
24 **********************************************************************/
29 * Provides a function for checking if a word is a palindrome
32 #include <string> //For string
33 #include <algorithm> //For reverse
35 bool is_palindrome(std::string word){ //Checks if the provided word is a plindrome.
36 std::string rev=word; //Copy the string
37 std::reverse(rev.begin(), rev.end()); //Reverse the copied string
38 if(word.compare(rev)==0){ //True if string compare returns 0 i.e. both strings are equal.
41 else{ //False if string compare returns non-zero i.e. strings are unequal.