D
D
DDD2019-02-28 15:04:48
C++ / C#
DDD, 2019-02-28 15:04:48

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;
    }
};

main.cpp
#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

1 answer(s)
S
Sergey Sakhno, 2019-02-28
@Kiberchief

convert string to one case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question