Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. int N = 1234 - 16*16 * 2;
  2. int Base = 16;
  3. String result = "";
  4.  
  5. while (N > 0) {
  6. result += (char)(N % Base);
  7. N /= Base;
  8. }
  9.  
  10. boolean isPalindrome = true;
  11. int strLen = result.length();
  12.  
  13. for (int i = 0; i < strLen/2; i ++) {
  14. if (result.charAt(i) != result.charAt(strLen - i - 1)) {
  15. isPalindrome = false;
  16. break;
  17. }
  18. }
  19. // abcba
  20. // a'''a
  21. // 'b'b'
  22. // 2 13 2 (2D2) is palindrome
  23. System.out.println(isPalindrome);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement