-
-
Save folivetti/605f29b053a6edd05c08e610aaf61718 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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