//Reverse_string.h
#ifndef REVERSE_STRING_H
#define REVERSE_STRING_H
#include<string> // #include<cstring> will cause error!
string Reverse(string str)
{
string S;
int n=str.size();
while(n>0)
{
n--;
S+=str[n];
}
return S;
}
string Convert(string str)
{
int n=str.size();
while(n>0)
{
n--;
if(str[n]>=65&&str[n]<=90) str[n]+=32; //convert capital letter into small letter,in order to ignore the form
//str[n]=(str[n]>90? str[n]+32:str[n]);
}
return str;
}
string Ignore(string str)
{
int n=str.size();
string s;
for(int i=0;i<n;i++)
{
if((str[n]>=65&&str[n]<=90)||(str[n]>=97&&str[n]<=122))
s+=str[i];
}
return s;
}
#endif
///////////////////////////////////////////////////
//main()
#include<iostream>
using namespace std;
#include "Reverse_string.h"
void main()
{
string str1;
while(cin>>str1){ //exit when press "Ctrl+Z"
int len=str1.size();
string s=Convert(Ignore(str1));
if(Reverse(s)==s)
cout<<"True!"<<endl;
else cout<<"False!"<<endl;
}
}
评论