leetcode 9

Posted 晴朗

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 };

 

以上是关于leetcode 9的主要内容,如果未能解决你的问题,请参考以下文章