LeetCode题解——Reverse Integer
题目:
数字翻转,即输入123,返回321;输入-123,返回-321。
代码:
 class Solution {
 public:
     int reverse(int x) {
         int result = , sign = ;
         if(x < )      //负数转换为正数统一处理
         {
             x = -x;
             sign = -;
         }
         while(x != )
         {
             result *= ;
             result += x % ;
             x /= ;
         }
         return result * sign;    //返回时记得加上符号
     }
 };
LeetCode题解——Reverse Integer的更多相关文章
- leetcode题解||Reverse Integer 问题
		problem: Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 ... 
- LeetCode 7 Reverse Integer(反转数字)
		题目来源:https://leetcode.com/problems/reverse-integer/ Reverse digits of an integer. Example1: x = 123, ... 
- [LeetCode 题解]: Reverse Nodes in K-Groups
		前言 [LeetCode 题解]系列传送门: http://www.cnblogs.com/double-win/category/573499.html 1.题目描述 Given a li ... 
- leetcode:Reverse Integer 及Palindrome Number
		Reverse Integer Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, retur ... 
- LeetCode 7 Reverse Integer & int
		Reverse Integer 想用余10直接算,没想到 -123%10 是 7, 原因 -123-(-123//10*10) r=a-n*[a/n] 以上,r是余数,a是被除数,n是除数. 唯一不同 ... 
- Leetcode  7. Reverse Integer(水)
		7. Reverse Integer Easy Given a 32-bit signed integer, reverse digits of an integer. Example 1: Inpu ... 
- leetcode:Reverse Integer(一个整数反序输出)
		Question:Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 ... 
- [LeetCode][Python]Reverse Integer
		# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'https://oj.leetcode.com/problems/reverse ... 
- LeetCode 7. Reverse Integer(c语言版)
		题目: Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123Output: 321 Ex ... 
随机推荐
- linux学习笔记(3)-文件系统
			三大类文件类型 普通文件:包括文本文件.数据文件.可执行的二进制程序文件 目录文件:linux系统把目录看成一种特殊的文件,利用它构成了文件系统的树形结构 设备文件:把设备也看成是一个文件,例如你的鼠 ... 
- Extjs4 treePanel异步加载菜单(后台从数据库读取)
			运行环境:springMVC+mybatis 一.建表 说明:0表示此节点为非叶子节点,即此节点还包括了子节点:1表示此节点为叶子节点,即此节点没有子节点.:关于图标iconCls是从Extjs的文件 ... 
- 设置Cookie
			var Site=new Object(); Site.Cookie={ _expires:24*3600*1000, _domain:'.gdxxb.com', set:function(name, ... 
- POJ3297+map字符串处理
			简单的字符串处理题. 要注意细节! 附数据两组: ABCC abc ae AAA abc AAAA abc A a B a C a /* */ #include<stdio.h> #inc ... 
- hdu 4291 A Short problem
			数学题,找循环节!! 首先g(g(g(n)))=g(x) mod 1e9+7 则可知x有循环节1e9+7; 之后x=g(g(n)),则可算出g(n)的循环节,在算出n的循环节就可以了!! 代码如下: ... 
- UIActinSheet和UIActionSheetDelegate
			UIActinSheet和UIActionSheetDelegate 这个是就那个UIActionSheet对象 一般用来选择类型或者改变界面...还有更多应用 定义如下:UIActionSheet ... 
- nginx做负载均衡配置文件
			nginx做负载均衡是在反向代理的基础上做的,代码如下: ## Basic reverse proxy server ## ## Apache backend for www.baidu.com ## ... 
- 前阿里CEO卫哲谈阿里创业经验:如何找人、找钱、找方向?(不同的阶段分别有:时间优先、金额优先、比例优先,不要做平台,太难)
			新浪科技李根 整理报道 卫哲现在是御嘉基金的创始合伙人,他另一个更加知名的身份是阿里巴巴(B2B)前CEO,在2006年到2011年的时间里,卫哲见证了阿里巴巴如何利用人才.资本和方向选择一路壮大. ... 
- Qt之QtSoap(访问WebService)
			http://blog.csdn.net/u011012932/article/details/51673800 
- linux系统的crond服务
			linux系统中有一个服务,用来做周期性运行的例行任务,这个服务就是crond服务.执行这项服务的命令 就是crontab命令了.而linux下的任务调度又分为系统任务调度和用户任务调度两个大类. 系 ... 
