//************************************************************* //Palindrome Judgment program 回文判断程序 U6ex4 page235 //cin a sentence,cout its characters in reverse order //and judgment whether the input line is a palindrome //************************************************************* #include<iostream> #include<string> using namespace std;
string sen; string pal;//palindrome回文 int len,i,j;//len=length字符串的长度,i是for循环变量,j判断倒序与正序相同字符的个数 //如果它等于字符串总的长度,即为回文。 void main() { cout<<"please input a sentence\n"; getline(cin,sen);
cout<<"the reverse order is:\n"; len=sen.length(); j=0; //倒序与正序相同字符的个数,赋初值0