HW5.3

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的更多相关文章
- HW5.36
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW5.35
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW5.34
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW5.33
import java.util.Calendar; public class Solution { public static void main(String[] args) { long tot ...
- HW5.32
public class Solution { public static void main(String[] args) { int n1 = (int)(Math.random() * 5 + ...
- HW5.31
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW5.30
public class Solution { public static void main(String[] args) { for(int i = 3; i <= 1000; i++) i ...
- HW5.29
public class Solution { public static void main(String[] args) { int n1 = (int)(Math.random() * 5 + ...
- HW5.28
public class Solution { public static void main(String[] args) { System.out.printf("%s\t%s\n&qu ...
- HW5.27
public class Solution { public static void main(String[] args) { int totalCount = 0; int lineCount = ...
随机推荐
- Excel skills (2) -- 自动调整行宽列高
快捷键: 行宽,Alt + O + R + A; 列高,Alt + O + C + A;
- joda jar日期处理类的学习
转载:http://www.open-open.com/lib/view/open1348032952724.html 任何企业应用程序都需要处理时间问题.应用程序需要知道当前的时间点和下一个时间点, ...
- MXNet在64位Win7下的编译安装
注:本文原创,作者:Noah Zhang (http://www.cnblogs.com/noahzn/) 我笔记本配置比较低,想装个轻量级的MXNet试试,装完之后报错,不是有效的应用程序,找不到 ...
- java.io.IOException: Cannot run program "bash": error=12, Cannot allocate memory
java.io.IOException: Cannot run program , Cannot allocate memory 云服务器运行nutch报出的异常: 解决方案: http://daim ...
- PHP漏洞全解(三)-客户端脚本植入
本文主要介绍针对PHP网站的客户端脚本植入攻击方式.所谓客户端脚本植入攻击,是指将可以执行的脚本插入到表单.图片.动画或超链接文字等对象内.当用户打开这些对象后,黑客所植入的脚本就会被执行,进而开始攻 ...
- Memcached总结二:Memcached环境安装设置以及连接memcache服务器
1 在Ubuntu上安装Memcached 要在Ubuntu上安装Memcached,打开终端,然后输入以下命令: $sudo apt-get update $sudo apt-get install ...
- ANDROID_MARS学习笔记_S01原始版_016_Service
一.代码1.xml(1)main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayo ...
- C# Json处理日期和Table
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Ru ...
- Emmet(前身是zen coding)介绍和使用
Zen coding - 一种快速编写HTML/CSS代码的方法.它使用仿CSS选择器的语法来快速开发HTML和CSS - 由Sergey Chikuyonok开发. 现在它改名为了Emmet,并且搭 ...
- js中replace用法
js中replace的用法 replace方法的语法是:stringObj.replace(rgExp, replaceText) 其中stringObj是字符串(string),reExp可以是正则 ...