回文数,从前到后,从后到前都一样

把数字转成字符串来处理

 package com.rust.cal;

 public class Palindrome {
     public static boolean isPalindrome(int x) {
         String s = String.valueOf(x);
         String revers = new StringBuffer(s).reverse().toString();
         if (s.equalsIgnoreCase(revers)) {
             return true;
         }
         return false;
     }

     public static void main(String arg[]){
         int input = 123;
         if (isPalindrome(input)) {
             System.out.println("Yes");
         }    else {
             System.out.println("NO");
         }
     }
 }

Palindrome 回文数的更多相关文章

  1. leetcode4 Valid Palindrome回文数

    Valid Palindrome回文数 whowhoha@outlook.com Question: Given a string, determine if it is a palindrome, ...

  2. 有趣的数-回文数(Palindrome number)

    文章转自http://blog.163.com/hljmdjlln@126/blog/static/5473620620120412525181/ 做LC上的题"Palindrome num ...

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

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

  4. leetcode 9 Palindrome Number 回文数

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

  5. palindrome number(回文数)

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

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

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

  7. [Swift]LeetCode9. 回文数 | Palindrome Number

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

  8. [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product

    Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...

  9. [Swift]LeetCode564. 寻找最近的回文数 | Find the Closest Palindrome

    Given an integer n, find the closest integer (not including itself), which is a palindrome. The 'clo ...

随机推荐

  1. 543. Diameter of Binary Tree

    https://leetcode.com/problems/diameter-of-binary-tree/#/description Given a binary tree, you need to ...

  2. JavaScript设计模式_01_单例模式

    最近项目不太忙,难得有时间看看书,平时挺喜欢js这门语言.也看过很多高级教程,觉得自己还是比较热衷于js的设计模式.这一次重温一下<JavaScript设计模式与开发实践>,开篇为单例模式 ...

  3. openresty使用笔记(一)

    背景介绍 游戏经过一段时间的运营,发现了原来的设计缺陷太多,所以决定重新设计架构.使用到nginx作为核心并通过lua+redis设计实现自己的负载分配方案.先看看下面这张简单的架构图吧~ 从图上看, ...

  4. cpp(第十三章)

    1.动态(晚期)联编需要显示定义复制构造函数,赋值运算符,虚构函数. 2.纯虚类不能声明对象. 3.赋值运算符的特征标随类而异. 4.返回类型协变,重新定义继承的方法,应确保与原来的原型完全相同,但如 ...

  5. 【MyBatis源码分析】select源码分析及小结

    示例代码 之前的文章说过,对于MyBatis来说insert.update.delete是一组的,因为对于MyBatis来说它们都是update:select是一组的,因为对于MyBatis来说它就是 ...

  6. [附录]Discuz X2.5程序模块source功能处理目录注释

    /source/admincp后台管理 /source/admincp/cloud云平台项目 /source/admincp/menu后台扩展菜单目录 /source/admincp/moderate ...

  7. 快来领取一场专门讲解UTF-8与UTF-16编码算法的GitChat活动的免费名额

    微信扫一扫,可打开该GitChat活动页面 字符编码是计算机世界里最基础.最重要.最令人困惑的一个主题之一.不过,在计算机教材中却往往浮光掠影般地草草带过,甚至连一本专门进行深入介绍的专著都找不到(对 ...

  8. Python中的枚举

    在Python中想要实现枚举功能的方式比较多,可以通过字典这一数据结构,利用键与值的对应关系,可以实现枚举的功能. my_Enum={ 'red':1, 'yellow':2, 'blue':3 } ...

  9. 浅谈JavaScript递归

    递归:是指函数/过程/子程序在运行过程序中直接或间接调用自身而产生的重入现象.递归指的是一个过程:函数不断引用自身,直到引用的对象已知. //公园里面有200个桃子,每天吃掉一半,扔掉一个烂的,第6天 ...

  10. php中常用的处理字符串的函数

    1.将字符串转换为数组的函数:str_split() array str_split ( string $string [, int $split_length = 1 ] ) string:输入字符 ...