您的位置:首页 > 其它

判断一个字符串是否为回文

2014-07-11 10:46 295 查看
#include <iostream>
#include <string>
using namespace std;
int main()
{
string str;
while(cin>>str)
{    bool result=true;
string::size_type len=str.size();
for(string::size_type idx=0;idx!=len/2;idx++)
{
if (str[idx]!=str[len-1-idx])
{ result=false;
break;
}
}

if (result)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: