leetcode 9. 回文数

class Solution

{

public:

    bool isPalindrome(int x)

    {

        if (x<0)

        {

            return false;

        }

        else if (0<=x&&x<=9)

        {

            return true;

        }

        else

        {

            double y=0;

            int z=x;

            while (x)

            {

                if (y*10>2147483647)

                {

                    return false;

                }

                else

                {

                    y=y*10;

                    y+=x%10;

                    x/=10;

                }

            }

            if (z==y)

            {

                return true;

            }

            else

            {

                return false;

            }

        }

    }

};

你可能感兴趣的:(#,leetcode.1,--,100,算法,数据结构)