leetcode 9

判断回文数

 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 };

 

posted @ 2016-09-28 11:17  HYDhyd  阅读(103)  评论(0编辑  收藏  举报