//WowBull 判断输入的字符串是否是回文 并且无视大小写字母 以及标点符号与空格
#include <string>
#include <cassert>
#include <cstddef>
#include <iostream>
using namespace std;
//逆转字符串
string cycle(const string& modify){
if (modify.length() == 0)
return modify;
string kuai(modify);
for(size_t i = 0;i < modify.size()/2; i++){
string one = modify.substr(i,1);
string two = modify.substr(modify.size()-i-1,1);
kuai.replace(i,1,two);
kuai.replace(modify.size()-i-1,1,one);
}
return kuai;
}
//用toupper() 和tolower() 改变字符串的大小写 (一次只能改变一个字符的大小写)
string lowercase(const string& modify){
if (modify.length() == 0)
return modify;
string kuai(modify);
for(size_t i = 0; i < modify.length();++i)
kuai[i] = tolower(kuai[i]);
return kuai;
}
//删除指定位置上的字符
string eclips(const string& s,size_t i){
string k = s;
return k.erase(i,1);
}
//查找字符串上的不符合字符,并删除
string findcase(const string& modify){
if (modify.length() == 0)
return modify;
string s = modify;
string wow(":;,.' '");
size_t i = 0;
while(i != std::string::npos){
i = s.find_first_of(wow,i);
if(i == std::string::npos)
return s;
//i = s.find_first_of(wow,i);
s = eclips(s,i);
}
return s;
}
int main(){
string modify(" ");
cout << "Please input wow:"<< endl;
getline(cin,modify);
//cin >> modify;
modify = findcase(modify);
modify = lowercase(modify);
if (modify.compare(cycle(modify)))
cout << "It is not Wow /n";
else
cout <<"It is Wow"<<endl;
return 0;
}