Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pl1;
- /**
- *
- * @author Joel
- */
- public class EX2 {
- public static void main(String[] args) {
- // TODO code application logic here}
- System.out.println(palindrome(97079, 0, 5));
- }
- public static int primeiroAlg(int d) {
- do {
- d = d / 10;
- } while (d > 9);
- return d;
- }
- public static boolean palindrome(int numero, int i, int j) {
- System.out.println(primeiroAlg(numero));
- if (i < j) {
- if (primeiroAlg(numero) != numero % 10) {
- return false;
- }
- i++;
- j--;
- numero = numero / 10;
- System.out.println("subtrair" + Math.pow(10, j - 1) * primeiroAlg(numero));
- numero = numero - (int) Math.pow(10, j - 1) * primeiroAlg(numero);
- System.out.println("numero: " + numero);
- palindrome(numero, i, j);
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement