leetcode-125. 验证回文串
题目:
代码:
#include <iostream>
#include <string>
using namespace std;
bool isPalindrome(string s) {
string str="";
for(int i=0;i<s.size();i++){
if(isalnum(s[i])){
str+=tolower(s[i]);
}
}
string str2(str.rbegin(),str.rend());
return str==str2;
}
int main(){
bool res;
string s;
cin>>s;
res=isPalindrome(s);
if(res){
cout<<"true";
}else{
cout<<"false";
}
return 0;
}