package pl.am.liczby.palindrom;
public class Palindrom {
public static boolean czyPalindrom(String text) {
for (int i=0; i<text.length()/2; i++) {
char znak = text.charAt(i);
char przeciwnyZnak = text.charAt(text.length() -1 -i);
if (znak != przeciwnyZnak) {
return false;
}
}
return true;
}
public static boolean czyPalindrom(long liczba) {
return czyPalindrom(Long.toString(liczba));
}
public static void main(String[] args) {
System.out.println(czyPalindrom("Ala"));
System.out.println(czyPalindrom("a aaa"));
System.out.println(czyPalindrom("abcddcba"));
System.out.println(czyPalindrom("xyzzyx"));
System.out.println(czyPalindrom("aaaab"));
System.out.println(czyPalindrom("fdajsfa"));
System.out.println("liczby:");
System.out.println(czyPalindrom(1234321));
System.out.println(czyPalindrom(1234554321));
System.out.println(czyPalindrom(1234));
System.out.println(czyPalindrom(782376));
}
}