华为机试—回文字符串
2014-12-27 21:59
260 查看
给出一个长度不超过1000的字符串,判断它是不是回文(顺读,逆读均相同)的。
#include <iostream> #include <cstring> using namespace std; int huiwen(char *a){ int len = strlen(a); int i,j=len-1; for(i=0;i<len/2;i++,j--){ if(a[i]!=a[j]){ return 0; } } return 1; } int main(){ char a[1001]; while(cin>>a){ if(huiwen(a)) cout<<"Yes!"<<endl; else cout<<"No!"<<endl; } cout<<endl; return 0; }
相关文章推荐
- 华为机试—回文字符串
- 华为机试:将字符串里第一次出现的字符输出,重复出现的不显示
- 2014年7月华为校招机试真题3
- 华为机试【按要求输出偶数,奇数之和】
- 牛客网_华为机试_004_字符串分割
- 华为机试——统计数字出现次数
- 牛客网_华为机试_023_删除字符串中出现次数最少的字符
- 华为机试 频率最高 频率最低的 单词
- 字符串四则运算表达式的计算(华为机试)
- 华为机试在线编程(一)
- 【华为机试】字符串分隔
- 【华为机试】简单密码
- 【华为机试】求最大连续bit数
- 华为机试在线练习题
- 华为机试——03操作系统任务调度问题
- 华为机试day3
- 《华为机试在线训练》之汽水瓶
- 牛客网三道编程题(六) 之华为机试在线训练(五)对随机数字去重、排序;取近似值
- 华为机试——完美数计算
- 华为机试——自守数