#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using std::cout;
using std::endl;
using std::cin;
using std::vector;
using std::string;
bool test(string str)
{
if(str=="")
{
return false;
}
string tmp = str;
reverse(tmp.begin(), tmp.end());
if(tmp == str)
{
return true;
}
else
{
return false;
}
}
string change(string str)
{
string result = "";
for(string::size_type ix = 0; ix != str.size();++ix)
{
if(isalpha(str[ix]))
{
result += toupper(str[ix]);
}
}
return result;
}
int main()
{
int num;
cin>>num;
string word;
getline(cin,word);
vector<string> svec;
for(int i=0;i<num;i++)
{
getline(cin,word);
svec.push_back(word);
}
for(vector<string>::size_type ix =0; ix <svec.size(); ++ix)
{
if(test(change(svec[ix])))
{
cout<<svec[ix]<<" is a palindrome."<<endl;
}
else
{
cout<<svec[ix]<<" is not a palindrome."<<endl;
}
}
return 0;
}
1008
最新推荐文章于 2019-04-22 16:51:15 发布