找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2703|回复: 0

[代码与实例] Lintcode491 Palindrome Number solution 题解

15

主题

15

帖子

15

积分

贫民

积分
15
Jenny 发表于 2018-6-21 21:58:34 | 显示全部楼层 |阅读模式
【题目描述】
Check a positive number is a palindrome or not.
A palindrome number is that if you reverse the whole number you will get exactly the same number.
Notice
It's guaranteed the input number is a 32-bit integer, but after reversion, the number may exceed the 32-bit integer.
判断一个正整数是不是回文数。
回文数的定义是,将这个数反转之后,得到的数仍然是同一个数。
注意事项
给的数一定保证是32位正整数,但是反转之后的数就未必了。

【题目解析】
这道题很明显是一道数学题,计算一个数字是否是回文数字,我们其实就是将这个数字除以10,保留他的余数,下次将余数乘以10,加上这个数字再除以10的余数.
需要注意的点:
1、负数不是回文数字.
2、0是回文数字.





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表