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. h5connect.js 腾讯云视频点播使用指南

    http://video.qcloud.com/download/docs/QVOD_Player_Web_SDK_Developer_Guide.pdf 腾讯云视频点播服务 Web播放器SDK开发指 ...

  2. 02.Lua的数据类型

    简单认识Lua 百度了一下(偷哈懒就不自己写了) Lua 是一个小巧的脚本语言.是巴西里约热内卢天主教大学(Pontifical Catholic University of Rio de Janei ...

  3. python 解决递归调用栈溢出

    递归函数 2578次阅读 在函数内部,可以调用其他函数.如果一个函数在内部调用自身本身,这个函数就是递归函数. 举个例子,我们来计算阶乘n! = 1 x 2 x 3 x ... x n,用函数fact ...

  4. C程序设计语言练习题1-8

    练习1-8 编写一个统计空格.制表符与换行符个数的程序. 代码如下: #include <stdio.h> // 包含标准库的信息. int main() // 定义名为main的函数,它 ...

  5. Struts2学习笔记--Struts例子及开发流程

    参考资料:http://blog.csdn.net/hntyzgn2010/article/details/5547753 http://chenlh.iteye.com/blog/464341 入门 ...

  6. Ubuntu 下安装使用文件比较合并图形工具Meld

    Meld是一款跨平台的文件比较合并工具使用Python开发,具体内容参照官网:http://meldmerge.org/ 注意以下环境要求: Requirements Python 2.7 (Pyth ...

  7. Codeforces 543D Road Improvement

    http://codeforces.com/contest/543/problem/D 题意: 给定n个点的树 问: 一开始全是黑边,对于以i为根时,把树边白染色,使得任意点走到根的路径上不超过一条黑 ...

  8. 自制单片机之十八……无线通讯模块NRF24L01+

    (一)基础知识篇 今天刚调试好,先看图吧! 这张是AT89C2051控制NRF24L01+做发射调试. 看看NRF24L01细节吧! 这是LCD屏显示: AT89S52做接收测试: 正在接收时的显示: ...

  9. KEIL段协定

    段名转换 Cx51编译器生成的目标代码(程序代码.程序数据和常数数据)保存在代码段或数据段中,一个段可以是可重定位的或绝对的,每个可重定位段有一个类型和一个名称.本节说明Cx51编译器命名这些段的惯例 ...

  10. DateTime字段控件值显示短格式的做法

    后台取dateTime格式,前台格式化就好了 <input type="text" name="txtPartyTime" id="txtPar ...