Search
 
SCRIPT & CODE EXAMPLE
 

CPP

is plaindrome

#include <iostream>
#include <deque>
bool is_palindrome(const std::string &s){

    if(s.size() == 1 ) return true;
    std::deque<char> d ;
    for(char i : s){
        if(std::isalpha(i)){
           d.emplace_back( toupper(i) );
        }
    }

    auto front = d.begin();
    auto back = d.rbegin();
    while( (front != d.end()) || (back != d.rend())){
        bool ans = (*front == *back);
        if(!ans){
            return ans;
        }
        ++front;++back;
    }

    return true;


}

int main() {
    std::string s = "A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal-Panama!";
    std::cout << std::boolalpha << is_palindrome(s) << std::endl;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: ue4 foreach loop c++ 
Cpp :: unreal ensureMsgf example 
Cpp :: C++ How to insert and print array elements? 
Cpp :: C++ Features 
Cpp :: columntransformer onehotencoder 
Cpp :: vector übergeben c++ 
Cpp :: vector of vector definaion in c++ 
Cpp :: arrays to function c++ 
Cpp :: deadlock detection in c++coding ninjas 
Cpp :: tempcoderunnerfile.cpp:1:1: error: does not name a type 
Cpp :: c++ union set q5 
Cpp :: c++ n in regex 
Cpp :: permutation and combination program in c++ 
Cpp :: 976. Largest Perimeter Triangle leetcode solution in c++ 
Cpp :: converting a for loop to a while loop C++ 
Cpp :: Integer Literrals in C++ Programming 
Cpp :: print all chrchetrs of a string c++ 
Cpp :: c++ get last element in array 
Cpp :: sort c++ array 
Cpp :: deletion in bst 
Cpp :: c++ quicksort 
Cpp :: pre increment vs post increment c++ 
Cpp :: cout<<"helloworld"<<endl problem 
C :: generate n-bit gray code in c 
C :: pygame detect click 
C :: C overwrite last line 
C :: restart nginx in alpine linix 
C :: calculator in c 
C :: c for schleife 
C :: print bool c 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =