判断一个字符串是否为回文
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; } }
相关文章推荐
- 判断一个字符串是否为回文
- 使用bool函数判断一个字符串是否为回文字符串
- java 记——课本例题,判断一个字符串是否是回文
- C实例--判断一个字符串是否是回文数
- 判断一个字符串是否为回文的非递归算法
- 判断一个字符串是否回文?
- C#--第2周实验--任务7--编写一个控制台应用--判断S所指的字符串是否回文(即顺读和逆读相同的字符串)
- 判断一个字符串、整数是否为回文字符串或回文数
- 判断一个字符串是否为回文,以及求一个字符串中最长回文串
- 队列-----判断一个字符串是否是回文
- 判断一个字符串是否为回文
- 判断一个字符串是否是回文,如果是,返回字符串“yes”,如果不是,返回字符串“no”
- 判断一个字符串是否有回文
- 【C语言】判断一个数是否为回文字符串
- 将一个字符串放在另一个字符串最前面or最后面,判断是否是能回文字符串
- 判断一个字符串是否为回文-链队(新建,进队,出队),链栈(新建,进栈,出栈)
- 简单递归____判断一个字符串是否为回文
- 判断一个字符串是否为回文的非递归算法
- 算法基础——判断一个字符串至多添加一个字符之后是否回文
- 判断一个字符串通过变化字符的位置,是否可以组成回文