zhiye_wang

向星空仰望的越深,越发现自己的渺小

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  31 随笔 :: 1 文章 :: 2 评论 :: 0 Trackbacks
 1 #include "stdafx.h"
 2 #include "iostream"
 3 
 4 using namespace std;
 5 
 6 int isechol (const char* str)
 7 {
 8     int length = strlen(str);
 9     for (int i=0; i<length/2; i++)
10     {
11         // 0代表不是,1代表是
12         if (str[i] != str[length-i-1])
13         {    
14             return 0;
15         }
16     }
17     return 1;
18 }
19 
20 int main(int argc, char* argv[])
21 {
22     printf("Hello World!\n");
23     char buf[10] = "abcddcba";
24     if (isechol(buf))
25         cout << buf << " is echol" << endl;
26     else
27         cout << buf << " is not echol" << endl;
28     return 0;
29 }
输出:
Hello World!
abcddcba is echol
Press any key to continue
posted on 2014-06-12 09:50 zhiye_wang 阅读(350) 评论(2)  编辑 收藏 引用 所属分类: C/C++通用

评论

# re: (3)判断回文字符串 2014-06-12 15:48 ccsdu2009
函数明显写的有问题.  回复  更多评论
  

# re: (3)判断回文字符串 2014-12-23 18:01 zhiye
谢谢指出。@ccsdu2009
  回复  更多评论
  


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理