Skip to content

Instantly share code, notes, and snippets.

@folivetti
Created March 5, 2017 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save folivetti/605f29b053a6edd05c08e610aaf61718 to your computer and use it in GitHub Desktop.
Save folivetti/605f29b053a6edd05c08e610aaf61718 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
class Main {
public static int inverte(int x) {
int resto, inverso = 0;
while (x!=0) {
resto = x%10;
inverso = inverso*10 + resto;
x = x/10;
}
return inverso;
}
public static void main(String[] args) {
int n;
Scanner leitor = new Scanner(System.in);
n = leitor.nextInt();
if (n==inverte(n)) {
System.out.println("palindromo");
} else {
System.out.println("não");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment