Guest User

Untitled

a guest
Jun 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string>
  3. #include <stdexcept>
  4. #include <iostream>
  5.  
  6. class Palindrome{
  7. public:
  8. static bool isPalindrome(const std::string &word){
  9. int stringLength=word.length();
  10. for(int i=0; i<stringLength; i++){
  11. if(tolower(word[i])!=tolower(word[stringLength-i-1])){
  12. //converting chars in string to lower case for comparison
  13. //cout<< "wordArray["<<i<<"] != wordArray["<<stringLength-i-1<<"]"<<endl; //debug
  14. return false;
  15. }
  16. }
  17. return true;
  18. }
  19. };
Add Comment
Please, Sign In to add comment