LeetCode Reverse Integer
2015-11-01 23:42
330 查看
//考虑越界问题
#include<stdio.h> int reverse(int x) { if(x>0&&x>INT_MAX)return 0; if(x<0&&(-x)>INT_MAX) return 0; long res = 0; while(x) { res = res*10 + x%10; x /= 10; } if(res>0&&res>INT_MAX)return 0; if(res<0&&(-res)>INT_MAX) return 0; return res; }
相关文章推荐
- 推荐
- 谁是凶手
- 11.1 python之webpy获取请求参数,把数据库结果放到List,Retrofit Post
- PAT1020 Tree Traversals
- 模拟IIC协议驱动气压传感器bmp085
- 秋招面试中常见题型以及知识点总结
- Spring开发包镜像下载地址
- 对象作为参数的连续传递(有点乱。。)
- [LeetCode] Word Search 的非递归实现
- spring注解中的@Autowired和@Component基本作用
- Java集合 Json集合之间的转换
- 数据存储(沙盒,偏好,归档)
- fipsql
- 打桩 转
- Linux ssh-keygen生成公钥和私钥
- 期中复习
- Appdelegate和Windos内容的简单介绍
- fips1101
- iOS 9: UIStackView入门
- ionic调试“死亡白屏”