赞
踩
-
- public class isPalindrome {
- public static boolean isPalindrome(int x) {
- if (x<0 || (x!=0 && x%10==0)) return false;
- int rev = 0;
- while (x>rev){
- rev = rev*10 + x%10;
- x = x/10;
- }
- return (x==rev || x==rev/10);
- }
-
- public static void main(String[] args) {
- System.out.println(isPalindrome(13231));
- System.out.println(isPalindrome(13233));
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。