• 7.整数反转


    7.整数反转

    方法一

    class Solution:
        def reverse(self, x):
            """
            :type x: int
            :rtype: int
            """
            
            flag = 0
            if x < 0:
                flag = 1
                x = abs(x)
            res = 0
            while x > 0:
                res = res * 10
                temp = x % 10
                res += temp
                x = x // 10
            if res < (-2) ** 31 or res > (2) ** 31 -1:
                return 0
            if flag == 1:
                return -res
            return res
  • 相关阅读:
    request相关
    C#请求接口
    qml_base
    web
    entry
    listbox
    Canvas
    pickle
    c#枚举
    数据结构——树
  • 原文地址:https://www.cnblogs.com/xiao-xue-di/p/10286792.html
Copyright © 2020-2023  润新知