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. 记录一下最近开发web移动前端的过程

    两个项目 第一个是公司网站的移动端,我所在的公司是做某方面的新闻站的. 所以说页面基本是以一条条的新闻+图文混排为主,顶部有一个自动slider+触屏滑动的功能, 使用的是swipe插件,轻量,简洁非 ...

  2. [Mugeda HTML5技术教程之5] 创建新作品

    前一节,我们介绍了Mugeda Studio.这一节我们讲一下怎么通过Studio创建新作品.首先登陆网站,如果还没有登陆账号,你可以登录 www.mugeda.com 免费注册一个.登录网站后,点击 ...

  3. PS 色彩的色相谱

    7- 色彩的色相谱 在这个环中,位于180度夹角的两种颜色(也就是圆的某条直径两端的颜色),称为反转色,又称为互补色.互补的两种颜色之间是此消彼长的关系,小框往蓝色移动的同时就会远离黄色, 黄色=白色 ...

  4. 网站UV,与IP、PV

    什么是网站UV,与IP.PV在概念上的区别? UV(独立访客):即Unique Visitor,访问您网站的一台电脑客户端为一个访客.00:00-24:00内相同的客户端只被计算一次. PV(访问量) ...

  5. 自适应 or 移动前端页面布局的问题?

    说出来,还请各位看官不要笑 - -.哥们至今不是很清楚页面的自适应和移动前端页面开发有什么区别 .有幸哪位看官清楚这些的话,希望能不吝赐教 .A.meta        <meta name=& ...

  6. MySQL 查询结果保存为CSV文件

    MySQL支持将查询结果直接导出为文本格式,格式如下: into outfile '导出的目录和文件名'                  指定导出的目录和文件名 fields terminated ...

  7. PYTHON-进阶-ITERTOOLS模块

    PYTHON-进阶-ITERTOOLS模块小结 这货很强大, 必须掌握 文档 链接 pymotw 链接 基本是基于文档的翻译和补充,相当于翻译了 itertools用于高效循环的迭代函数集合 组成 总 ...

  8. UILabel自适应高度和自动换行

    码: //初始化label UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)]; //设置自动行数与字符换行 [l ...

  9. 游览器对js加载的次序

    直接看例子 <body> <script> console.log("first"); var script = document.createElemen ...

  10. 请问FMX手机app多个窗体如何嵌入同一个窗体?

    app有多个不同窗体,均调用相同的一个小窗体,因显示同一样的东西,如grid:如果每个窗体都重复加 小窗体的界面和代码,非常麻烦,而且编译后体积也很大: vcl中这样就行:  Form1:=TForm ...