Palindromtest.java 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import static de.nplusc.hhn.ZipInvert.invert;
  2. import java.io.BufferedReader;
  3. import java.io.InputStreamReader;
  4. /*
  5. * To change this template, choose Tools | Templates
  6. * and open the template in the editor.
  7. */
  8. /**
  9. *
  10. * @author LH
  11. */
  12. public class Palindromtest
  13. {
  14. public static void main(String[] args) throws Exception //unfein; amchs nur wegen ihrer doofen limitierung
  15. {
  16. //System.out.println("dbg1");
  17. BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
  18. //System.out.println("dbg2");
  19. //System.out.print()
  20. System.out.print("Bitte Wort eingeben :");
  21. String line = kb.readLine();
  22. while(line!=null)
  23. {
  24. String rslt = (line.equals(invert(line))?"":"Kein ")+"Palindrom";
  25. System.out.println(rslt);
  26. line = kb.readLine();
  27. }
  28. }
  29. public static String invert(String in)
  30. {
  31. return in.length()<2?in:invert(in.substring(1))+in.substring(0,1);
  32. }
  33. }