码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode 9

时间:2016-09-28 12:19:28      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:

判断回文数

 1 class Solution {
 2 public:
 3     bool isPalindrome(int x) {
 4         std::stringstream ss;
 5         ss<<x;
 6         string str;
 7         ss>>str;
 8         for(int i=0,j=str.size()-1;i<j;i++,j--)
 9         if(str[i]!=str[j])
10         return 0;
11         return 1;
12     }
13 };

 

leetcode 9

标签:

原文地址:http://www.cnblogs.com/thefirstfeeling/p/5915613.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!