class Solution {
public:
bool isPalindrome(int x) {
int r=,init=x;
if(init==) return true;
if(init<) return false;
while(init!=){
r=r*+init%;
init=init/;
}
if(r==x)
return true;
else
return false;
}
};

题目:

  判断一个整数是不是回文数,即一个数翻转过来是否跟原来的数仍一样。

  需要考虑负数,负数无回文数。

解法:

  翻转提供的数字,即123的话,需要翻转为321.

  再判断翻转后两个数字还是否相同。

LeetCode OJ Palindrome Number(回文数)的更多相关文章

  1. leetcode 9 Palindrome Number 回文数

    Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. S ...

  2. Leetcode 3——Palindrome Number(回文数)

    Problem: Determine whether an integer is a palindrome. Do this without extra space. 简单的回文数,大一肯定有要求写过 ...

  3. [LeetCode]9. Palindrome Number回文数

    Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...

  4. 【LeetCode】Palindrome Number(回文数)

    这道题是LeetCode里的第9道题. 题目说的: 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121 输出: true 示例 2: ...

  5. LeetCode Problem 9:Palindrome Number回文数

    描述:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could nega ...

  6. 【LeetCode】9. Palindrome Number 回文数

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 公众号:负雪明烛 本文关键词:回文数,回文,题解,Leetcode, 力扣,Python ...

  7. [LeetCode] Prime Palindrome 质数回文数

    Find the smallest prime palindrome greater than or equal to N. Recall that a number is prime if it's ...

  8. Palindrome Number 回文数

    判断一个数字是否是回文数,尝试不用其他额外空间. 注意: 负数也有可能成为回文数吗? 如果你想让int转为string,注意不用其他空间这个约束. 你也可以翻转一个int,但是有可能会溢出.     ...

  9. 【LeetCode】9 Palindrome Number 回文数判定

    题目: Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could neg ...

  10. 9. Palindrome Number 回文数的判断

    [抄题]: Determine whether an integer is a palindrome. An integer is a palindrome when it reads the sam ...

随机推荐

  1. js常用代码收集

    1. PC - js 返回指定范围的随机数(m-n之间)的公式 Math.random()*(n-m)+m return false return false // event.preventDefa ...

  2. Codeforces-Salem and Sticks(枚举+思维)

    Salem gave you nn sticks with integer positive lengths a1,a2,-,ana1,a2,-,an. For every stick, you ca ...

  3. P2905 [USACO08OPEN]农场危机Crisis on the Farm

    传送门 DP 设 f [ i ] [ j ] [ k ] 表示已经走了 i 步,向上走了 j 步,向右走了 k 步时能拯救的最多奶牛数(j,k可以为负,表示反向) 设 g [ i ] [ j ] 表示 ...

  4. 75th LeetCode Weekly Contest Smallest Rotation with Highest Score

    Given an array A, we may rotate it by a non-negative integer K so that the array becomes A[K], A[K+1 ...

  5. Python的Profilers性能分析器

    关于Python Profilers性能分析器 关于性能分析,python有专门的文档,可查看:http://docs.python.org/library/profile.html?highligh ...

  6. sshd_config注释

    [root@H0f ~]# cat /etc/ssh/sshd_config #update by H0f -- # $OpenBSD: sshd_config,v // :: djm Exp $ # ...

  7. java——简易版build模式

    参考教程:https://blog.csdn.net/fanxudonggreat/article/details/78927773 public class Computer { private S ...

  8. 时间戳date 命令

    时间戳date  命令 [chenxiaohao@iZbp1c0q444r0hp2gq8lhmZ server]$ echo $(date +%Y%m%d)  ——————>今天 2018032 ...

  9. JavaScript 将数组中具有相同值的对象 取出组成新的数组

    var arr=[{name:2,id:3},{name:2,id:4},{name:3,id:5},{name:3,id:6},{name:1,id:1},{name:1,id:2}]; // 传入 ...

  10. SQL---MySQL数据库---聚合函数

    1.数值 format(x,n) 将x格式化为  由逗号分隔,小数点后n 位的数: