**6.3(回文整数)使用下面的方法头编写两个方法:
//Return the reversal of an integer,i,e.,reverse(456) returns 654 public static int reverse(int number) //Return true if number is a palindrome public static boolean isPalindrome(int number)
1 import java.util.*; 2 3 public class o { 4 5 public static int reverse(int number) { 6 int eve; 7 int s = 0; 8 int an = number;//eve是余数,an是除数 9 while(an != 0) { 10 eve = an % 10; 11 s=s * 10 + eve; 12 an /= 10; 13 } 14 return s; 15 } 16 public static boolean isPalindrome(int number) { 17 boolean judge = true; 18 int eve; 19 int s = 0; 20 int an = number;//eve是余数,an是除数 21 while(an != 0) { 22 eve = an % 10; 23 s=s * 10 + eve; 24 an /= 10; 25 } 26 if(s!=number) { 27 judge = false; 28 } 29 return judge; 30 } 31 public static void main(String[] args) { 32 int number; 33 Scanner input = new Scanner(System.in); 34 System.out.print("请输入一个整数"); 35 number = input.nextInt(); 36 if((reverse(number)==number)&&isPalindrome(number)) { 37 System.out.println("这是一个回文整数"); 38 } 39 else { 40 System.out.println("这不是一个回文整数"); 41 } 42 } 43 }