Answer the question
In order to leave comments, you need to log in
How can I make my palindrome work not only with small letters but also with large letters too?
pal.h
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
class Palindrom {
public:
bool operator()(std::string s)
{
return (equal(s.begin(), s.begin() + s.size() / 2, s.rbegin())) ? true : false;
}
std::string removeSpaces(std::string s)
{
s.erase(std::remove(s.begin(),s.end(),' '),s.end());
return s;
}
std::string space(std::string s)
{
if(s.size()==0)
s.erase(std::remove(s.begin(),s.end(),' '),s.end());
return s;
}
};
#include <iostream>
#include "pal.h"
int main()
{
std::string s;
std::getline(std::cin,s);
Palindrom p;
if (p(p.space(p.removeSpaces(s))))
std::cout<<"Palindrom"<<std::endl;
else
std::cout<<"is NOT Palindrom"<<std::endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question