class Solution {
public:
    int reverse(int x) {
       ;//long 是怕中间过程溢出
        <<,max=-min-){
            ans=ans*+x%;
            x=x/;
        }
        if(ans>max||ans<min)
            ;
        return ans;
    }
};

注释:

  这是进制转换问题。

  转化过程中一定要考虑溢出。

  清楚各种类型的表示范围。

附 

32位平台:

unsigned   int   0~4294967295  
int    -2147483648~2147483647 (-2^31~(2^31-1))//补码比原码多表示1个数
unsigned long 0~4294967295
long   -2147483648~2147483647
long long的最大值:9223372036854775807
long long的最小值:-9223372036854775808
unsigned long long的最大值:1844674407370955161

__int64的最大值:9223372036854775807
__int64的最小值:-9223372036854775808
unsigned __int64的最大值:18446744073709551615

Reverse digits of an integer.的更多相关文章

  1. 【LeetCode】Reverse digits of an integer

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 Have you ...

  2. 【leetcode】1281. Subtract the Product and Sum of Digits of an Integer

    题目如下: Given an integer number n, return the difference between the product of its digits and the sum ...

  3. 翻转整数 Reverse digits of a number

    两种方法翻转一个整数.顺序翻转和递归翻转 这里没考虑overflow的情况 递归的作用是使得反向处理.即从递归栈的最低端開始处理.通过绘图可得. 假设是rec(num/10): 12345 1234 ...

  4. [Leetcode] 5279. Subtract the Product and Sum of Digits of an Integer

    class Solution { public int subtractProductAndSum(int n) { int productResult = 1; int sumResult = 0; ...

  5. LeetCode 7. Reverse Integer

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you ...

  6. [LeetCode] Reverse Integer 翻转整数

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to ...

  7. Reverse Integer LeetCode Java

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 public cl ...

  8. No.007:Reverse Integer

    问题: Reverse digits of an integer.Example1:x = 123, return 321Example2:x = -123, return -321 官方难度: Ea ...

  9. Reverse Integer

    Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 public cl ...

随机推荐

  1. dede调用指定的多个栏目导航

    {dede:channelartlist row=' typeid='1,2这里输入多个指定的栏目ID' } <li><a href='{dede:field name='typeu ...

  2. Java学习笔记--集合元素的比较Comparable,Comparator

    原文见: http://www.cnblogs.com/sunflower627/p/3158042.html 1. Comparator 和 Comparable 相同的地方 他们都是java的一个 ...

  3. Scala学习笔记--特质trait

    http://outofmemory.cn/scala/scala-trait-introduce-and-example 与Java相似之处 Scala类型系统的基础部分是与Java非常相像的.Sc ...

  4. div 居中进行总结

    1.margin:auto ;让元素居中,需要确定元素的宽度,并且需要是块元素 eg: div { width:200px; height:200px; background:#222; margin ...

  5. 使用jcifs.smb.SmbFile读取Windows上共享目录的文件

    protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws Servl ...

  6. Ubuntu下Vim 如何进入全屏编辑模式

    如题:F11进入全屏编辑模式,再按F11则退出全屏编辑模式.

  7. ASP.NET中默认的一级目录

    默认一级目录结构: /Controllers – 存放负责处理 存放负责处理 URL请求的控制器类: 类:/Models – 存放表示和操纵数据以及业务对象的类: /Views – 存放负责呈现输出内 ...

  8. windows进程间通讯的方法

    版权声明 请尊重原创作品.转载请保持文章完整性,并以超链接形式注明原始作者“tingsking18”和主站点地址,方便其他朋友提问和指正.   1.使用共享内存 代码如下: void FileMapp ...

  9. 代理模式 - OK

    代理模式(Proxy),为其他对象提供一种代理以控制对这个对象的访问. 在某些情况下,一个对象不适合或者不能直接引用另一个对象,而代理对象可以在客户端和目标对象之间起到中介的作用. 代理模式的优点: ...

  10. 为什么Application_BeginRequest会执行两次

       大家也看到了,很奇怪的是我们明明就请求了一个页面,页面中也没有其他的图片请求.为什么Application_BeginRequest会被执行了两次呢?!既然他请求,那我们看看他到底在请求什么就是 ...