leetcode 9:回文数

bool isPalindrome(int x) {
        vector<int> a;
        if(x<0)
            return false;
        if(x==0)
            return true;
        if(x>0){
            while(x/10!=0){
                a.push_back(x%10);
                x=x/10;
            }
            a.push_back(x%10);
            
            int len=a.size();
            for(int i=0;i<len/2;i++){
                if(a[i]!=a[len-i-1])
                    return false;
            }
            return true;
        }
    }

 

相关文章:

  • 2022-12-23
  • 2021-05-18
  • 2021-08-08
  • 2021-10-30
  • 2022-02-14
  • 2021-12-01
  • 2021-06-24
  • 2021-10-31
猜你喜欢
  • 2022-01-13
  • 2021-04-17
  • 2021-07-28
  • 2021-12-19
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案