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. MVC-各种传值方式

    [转自]:QLeelulu示例一:ViewData传值.HomeController.cs Co de: public ActionResult Index(){     ViewData[" ...

  2. struts2用了哪几种模式

    代理模式 责任连模式 ActionVacation 迭代模式

  3. bug - colorWithPatternImage:

    // 在ios5之前, 再通过以下方法设置背景时, 有闪屏bug self.view.backgroundColor = [UIColor colorWithPatternImage:<#(no ...

  4. web中自定义鼠标样式

    实现一个功能:鼠标移动到一个图片左边显示左箭头,移动到右边显示右箭头. 实现方法:一个img上面定位两个div,div的样式如下: .toleft { width: 200px; height: 30 ...

  5. python参考手册--第10、11章执行环境、调试

    1.解释器选项和环境 python [options] [-c cmd | filename | - ] [args] 例如:python -m pdb test.py 以脚本的形式运行库模块pdb ...

  6. php多线程thread开发与应用的例子

    Php多线程的使用,首先需要PHP5.3以上版本,并安装pthreads PHP扩展,可以使PHP真正的支持多线程,扩展如何安装请自行百度 PHP扩展下载:https://github.com/kra ...

  7. POJ 1135 Domino Effect(Dijkstra)

    点我看题目 题意 : 一个新的多米诺骨牌游戏,就是这个多米诺骨中有许多关键牌,他们之间由一行普通的骨牌相连接,当一张关键牌倒下的时候,连接这个关键牌的每一行都会倒下,当倒下的行到达没有倒下的关键牌时, ...

  8. android 案例:从另一个activity选择信息并获取返回值

    主窗口: package com.example.test; import android.app.Activity; import android.app.AlertDialog; import a ...

  9. Java二维数组

    package com.test; public class Test { public static void main(String[] args) { // TODO Auto-generate ...

  10. 131. Palindrome Partitioning

    题目: Given a string s, partition s such that every substring of the partition is a palindrome. Return ...