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

把数字转成字符串来处理

 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. Caffe代码分析--crop_layer.cu

    因为要修改Caffe crop layer GPU部分的代码,现将自己对这部分GPU代码的理解总结一下,请大家多多指教! crop layer完成的功能(以matlab的方式表示):A(N,C,H,W ...

  2. 最短路径Floyd算法【图文详解】

    Floyd算法 1.定义概览 Floyd-Warshall算法(Floyd-Warshall algorithm)是解决任意两点间的最短路径的一种算法,可以正确处理有向图或负权的最短路径问题,同时也被 ...

  3. 【论文:麦克风阵列增强】An alternative approach to linearly constrained adaptive beamforming

    作者:桂. 时间:2017-06-03  21:46:59 链接:http://www.cnblogs.com/xingshansi/p/6937259.html 原文下载:http://pan.ba ...

  4. JavaScript中for循环的使用详解

    or循环是循环最紧凑的形式,并包含有以下三个重要部分组成: 循环初始化计数器的初始值.初始化语句执行循环开始之前. 测试语句,将测试如果给定的条件是真还是假.如果条件为真,那么将要执行的循环中给定的代 ...

  5. python学习笔记之列表与元组

    一.概述 python包含6种内建的序列,其中列表和元组是最常用的两种类型.列表和元组的主要区别在于,列表可以修改,元组则不能修改 使用上,如果要根据要求来添加元素,应当使用列表:而由于要求序列不可修 ...

  6. Linux回炉复习系列文章大纲

    本人最近在回炉Linux的内容,也做了很多整理,顺便也想将整理的内容分享出来. 由于该系列文章的内容主要是复习整理而来,其中绝大多数命令都是翻译和整理man或info文档总结的,另外很多地方也没有给出 ...

  7. javascript基础数据类型与引用类型

    javascript一共有6种数据类型 有5种基本类型:Null,String Number,Boolean,Undefined 和一种引用类型Object 基础类型在内存中存在于栈空间中,例如 va ...

  8. 删除iPhone图片,提示“没有删除此项目的权限”

    解决方法:设置-照片与相机-iCloud照片图库-关闭 (IOS10)

  9. [css 实践篇] CSS box-orient

    定义和用法 box-orient 属性规定框的子元素应该被水平或垂直排列. 提示:水平框中的子元素从左向右进行显示,而垂直框的子元素从上向下进行显示.不过,box-direction 和 box-or ...

  10. Ecshop去掉模版中随机出现Ecshop版权的方法

    EC如果是免费用户用的话,模版里面会随机出现 powered by ecshop 的字样,看了一下原来是在COMMON.JS里面写的一段代码,删除掉就可以解决掉了,方法如下: 打开  js/commo ...