Python, LintCode, 37. 反转一个3位整数

class Solution:
    """
    @param number: A 3-digit number.
    @return: Reversed number.
    """
    def reverseInteger(self, number):
        # write your code here
        h = int(number/100)
        t = int(number%100/10)
        z = int(number%10)
        return (100*z+10*t+h)
class Solution:
    """
    @param number: A 3-digit number.
    @return: Reversed number.
    """
    def reverseInteger(self, number):
        # write your code here
        temp = str(number)
        temp = temp[::-1]
        return int(temp)


你可能感兴趣的:(LintCode)