Determine whether an integer is a palindrome. Do this without extra space.

首先负数不是回文数。

对于正数,求一下它倒过来的数(即个位放在最高位,十位放在次高位。。。),如果结果与原数相同,则是回文数

    bool isPalindrome(int x) {if(x<0)return false;int temp=x;int pn=0;int max_inf=0x7fffffff;while(temp){if(pn>max_inf/10 || pn==max_inf/10&&(temp%10>max_inf%10))return false;pn*=10;pn+=temp%10;temp/=10;}if(pn==x)return true;return false;}

【9】Palindrome Number相关推荐

  1. 【Leetcode】Palindrome Number

    Determine whether an integer is a palindrome. Do this without extra space. 思路:若使用[Leetcode]Reverse I ...

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

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

  3. leetcode【537】Complex Number Multiplication(复数相乘)

    写在最前面:一道很常规的字符串分割的题 leetcode[537]Complex Number Multiplication Given two strings representing two co ...

  4. 【LeetCode】Palindrome Partitioning 解题报告

    [题目] Given a string s, partition s such that every substring of the partition is a palindrome. Retur ...

  5. 【HDOJ】1005 Number Sequence_天涯浪子_新浪博客

    [题目]http://acm.hdu.edu.cn/showproblem.php?pid=1005 [报告] 这道明显是数学题,但如果按位枚举显然是要TLE的. 仔细思考,它有一个MOD 7,这个很 ...

  6. 【u020】Couple number

    Time Limit: 1 second Memory Limit: 128 MB [问题描述] 任何一个整数N都能表示成另外两个整数a和b的平方差吗?如果能,那么这个数N就叫做Couple numb ...

  7. 【Python】数据类型 Number数字、String字符串、List列表、Tuple元组、Set集合、Dictionary字典

    Python数据类型 2021/6/3 周四 学习内容: Python数据类型.Number(数字).String(字符串).List(列表).Tuple(元组).Set(集合).Dictionary ...

  8. 【leetcode79】Single Number III

    题目描述: 给定一个数组,里面只有两个数组,只是出现一次,其余的数字都是出现两次,找出这个两个数字,数组形式输出 原文描述: Given an array of numbers nums, in wh ...

  9. 【HDU】1005 Number Sequence (有点可爱)

    http://acm.hdu.edu.cn/showproblem.php?pid=1005 A number sequence is defined as follows: f(1) = 1, f( ...

最新文章

  1. msf反弹shell
  2. 【压缩率3000%】上交大ICCV:精度保证下的新型深度网络压缩框架
  3. 利用__FILE__, __LINE__, __FUNCTION__跟踪调试程序
  4. 【问题记录】RIDE-1.7.3.1控制台及日志中文乱码处理
  5. 玩转linux——Screen管理远程会话,再也不怕关闭SSH就中断会话了
  6. Atitit 图片 验证码生成attilax总结
  7. 楚留香ai识别人脸_【专利解密】商汤科技:AI加持人脸识别
  8. Vue之解析PSD文件(文字)
  9. #原创分享# DDD领域建模---老调新弹之【实体】
  10. 解决mysql插入中文出现错误ERROR 1366 (HY000): Incorrect string value: ‘\x80\x85\xEF\xBC\x8C\xE6...‘ for column
  11. bert常用基准数据集:GLUE数据集介绍以及数据集资源
  12. 分布式架构中的八大谬误
  13. linux coreclr编译,.NET跨平台:在Linux Ubuntu上编译coreclr/corefx/dnx(20150617)
  14. 从新一代TPU到Google.ai,详解谷歌I/O首日人工智能五大亮点
  15. Freemarker 简介 及手册
  16. 计算机软件防干扰,抗干扰技术
  17. 我写了一个语音识别引擎
  18. QT常用函数总结(全)
  19. ZYNQ-ZedBoard 上运行桌面 LINUX
  20. 从苹果ATT新政第一年,看全球数据主权之争与治理规则的变迁

热门文章

  1. [转]dedeCMS SEO实战
  2. 微信支付 JSAPI
  3. distenct oracle_Oracle中distinct用法
  4. Minecraft:随时随地创造你的世界
  5. 蓝牙A2DP和HFP编解码
  6. pandas数据框loc属性语法及示例
  7. 韩の花样男子 全集跟踪BT下载 每周更新
  8. 好声响 卡登仕便携蓝牙音箱Beat SOHO
  9. 简单的声波动画js版本
  10. 第3章-数理知识基础 -> 矩阵分析