Horje
std::stack Code Example
std::stack
#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
bool is_palindrome(const std::string &s){
    std::stack<char> LIFO;
    std::queue<char> FIFO;
    for(auto &c: s){
        if(std::isalpha(c)){

            LIFO.push(std::toupper(c));
            FIFO.push(std::toupper(c));
        }
    }
    bool ans;
    while( (LIFO.size() && FIFO.size()) != 0){
        ans = (LIFO.top() == FIFO.front());
        if(!ans){
            return ans;
        }
        LIFO.pop(),FIFO.pop();
    }
    return true ;
}



int main() {
    try{
        std::string s ;
        std::cout << "Enter a string" << std::endl;
        std::cin >> s;
        std::cout << std::boolalpha << is_palindrome( s) << std::endl;
    }catch(std::exception &e){
     std::cout << e.what() << std::endl;
    }

    return 0;
}




Cpp

Related
binary exponentiation modulo m Code Example binary exponentiation modulo m Code Example
get line C++ Code Example get line C++ Code Example
max of a vector c++ Code Example max of a vector c++ Code Example
get thread id c++ Code Example get thread id c++ Code Example
change integer to string c++ Code Example change integer to string c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8