import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);
         System.out.print("Enter a number: ");
         int number = input.nextInt();

         input.close();

         System.out.println(number + " is a palindrome: " + isPalindrome(number));
     }

     public static int reverse(int number)
     {
         String strOfNumber = "";
         if(number < 10)
             strOfNumber += number + "";
         else
             strOfNumber += "" + number % 10 + reverse(number / 10);
         return Integer.parseInt(strOfNumber);
     }

     public static boolean isPalindrome(int number)
     {
         int backupNumber = reverse(number);
         if(number == backupNumber)
             return true;
         else
             return false;
     }
 }

HW5.3的更多相关文章

  1. HW5.36

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. HW5.35

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  3. HW5.34

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. HW5.33

    import java.util.Calendar; public class Solution { public static void main(String[] args) { long tot ...

  5. HW5.32

    public class Solution { public static void main(String[] args) { int n1 = (int)(Math.random() * 5 + ...

  6. HW5.31

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW5.30

    public class Solution { public static void main(String[] args) { for(int i = 3; i <= 1000; i++) i ...

  8. HW5.29

    public class Solution { public static void main(String[] args) { int n1 = (int)(Math.random() * 5 + ...

  9. HW5.28

    public class Solution { public static void main(String[] args) { System.out.printf("%s\t%s\n&qu ...

  10. HW5.27

    public class Solution { public static void main(String[] args) { int totalCount = 0; int lineCount = ...

随机推荐

  1. C#中如何按字节数截取字符串?

    http://www.cnblogs.com/xuejie/archive/2012/12/14/2818452.html

  2. Objective-c开发中混合使用ARC

    首选“Compile Sources”的位置: 选中工程->TARGETS->相应的target然后选中右侧的“Build Phases”,向下就找到“Compile Sources”了. ...

  3. 如何用 Retrofit 2 在安卓上实现 HTTP 访问?

    最近,笔者对安卓开发的兴趣愈发浓厚,而且不断尝试了许多传闻很棒的开发库 -- 大部分也真的很不错.于是打算写一个系列文章,介绍使用这些让人惊叹的库建立安卓示例应用的实践.这样,读者可以自行判断,这些库 ...

  4. WAF 与 RASP 的安装使用大比拼!

    什么是WAF和RASP? WAF全称是Web application firewall,即 Web 应用防火墙.RASP 全称是 Runtime Application Self-protect,即应 ...

  5. easyui源码翻译1.32--Draggable(拖动)

    前言 使用$.fn.draggable.defaults重写默认值对象.下载该插件翻译源码 源码 /** * jQuery EasyUI 1.3.2 * *翻译:qq 1364386878 --拖动 ...

  6. [codility]Falling-discs

    http://codility.com/demo/take-sample-test/omega2013 这题有点意思.首先经过思考,想到从底部往上扫,去迎接掉下来的disc.但这样仍然是不行的.后来看 ...

  7. FastJSON学习

    这几天在用FastJSON,发现需要测试一些关键点,包括: 1.是否支持内部类:测试结果是支持,但是需要设置为静态类(static) 2.是否支持继承的自动序列化及反序列化:测试结果是支持 3.缺字段 ...

  8. Sum of Digits / Digital Root

    Sum of Digits / Digital Root In this kata, you must create a digital root function. A digital root i ...

  9. APP-FND-01706: Error Updating TABLE_NAME In FND_DOCUMENT_SEQUENCES (文档 ID 338026.1)

    In this Document Symptoms Cause Solution Applies to: Oracle Order Management - Version 11.5.10.0 and ...

  10. c#反射重载方法(发现不明确的匹配)

    GetMethod(string name) 在反射重载方法时,如果调用此重载方法,会产生 发现不明确的匹配 的错误. 解决方案如下: GetMethod("MethodName" ...