Skip to content

Instantly share code, notes, and snippets.

@Yurlov
Created June 30, 2016 20:47
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 Yurlov/92ce192a8619be1a07f482ef23f2f9cf to your computer and use it in GitHub Desktop.
Save Yurlov/92ce192a8619be1a07f482ef23f2f9cf to your computer and use it in GitHub Desktop.
Prog.kiev.ua
public class PalindromSample {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int[] myArray = new int[10];
arrayFiller(in, myArray);
getPalindromNumber(myArray);
}
private static boolean isPalindromNumber(int number) {
String firstPart = Integer.toString(number);
String secondPart = "";
for (int num = firstPart.length()-1; num>=0; num--)
secondPart += firstPart.charAt(num);
return firstPart.equals(secondPart);
}
private static void getPalindromNumber(int array[]) {
int tmp = 0;
for (int elem : array) {
if (isPalindromNumber(elem)) {
tmp = elem;
}
}
System.out.println("Palindrom-number is :" + tmp);
}
private static void arrayFiller(Scanner in, int[] array) {
for (int i = 0; i < array.length; i++) {
array[i] = in.nextInt();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment