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. 小a与黄金街道(欧拉函数+快速幂)

    链接:https://ac.nowcoder.com/acm/contest/317/D 来源:牛客网 题目描述 小a和小b来到了一条布满了黄金的街道上.它们想要带几块黄金回去,然而这里的城管担心他们 ...

  2. P1029 最大公约数和最小公倍数问题(思维题)

    题目描述 输入22个正整数x_0,y_0(2 \le x_0<100000,2 \le y_0<=1000000)x0​,y0​(2≤x0​<100000,2≤y0​<=100 ...

  3. Diophantus of Alexandria

    Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...

  4. linux dns高速缓存

    1.安装部署dns yum install bind -y systemctl start  named systemctl  enable  named systemctl  stop  firew ...

  5. 云数据库 Redis 缓存 PHP session 变量

    1.安装 phpredis 扩展. wget https://github.com/nicolasff/phpredis/archive/master.zip unzip master.zip cd ...

  6. 1.搭建JavaEE开发环境

    1.Web应用介绍: 2.Servlet简介 3.JSP简介 4.Servlet容器 Web服务器有静态资源和动态页面,静态资源是*.html(文件系统),动态页面是Servlet容器. 5.Tomc ...

  7. 2.1 Rust概念

    标识符 The first character is a letter.The remaining characters are alphanumeric or _.或The first charac ...

  8. java——并查集 UnionFind

    时间复杂度: O(log*n),近乎是O(1)级别的 UnionFind 接口: public interface UF { int getSize(); boolean isConnected(in ...

  9. 关于JAVA的基本知识

    TCP/IP 协议族常用协议 应用层:TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet 等等 传输层:TCP,UDP 网络层:IP,ICMP,OSPF,EIGRP,IGMP 数据链 ...

  10. ssh RSA key变化后处理

    root@localhost:/# scp -r root@172.19.47.30:/home/linux-4.16.2-devm.1.2.aarch64.dongbo ./@@@@@@@@@@@@ ...