|
@@ -0,0 +1,71 @@
|
|
|
+
|
|
|
+import static de.nplusc.hhn.Zip.zip2;
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.InputStreamReader;
|
|
|
+import java.io.PrintStream;
|
|
|
+
|
|
|
+/*
|
|
|
+ * To change this template, choose Tools | Templates
|
|
|
+ * and open the template in the editor.
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author LH
|
|
|
+ */
|
|
|
+public class Palindromgenerator
|
|
|
+{
|
|
|
+ public static void main(String[] args) throws Exception //unfein; amchs nur wegen ihrer doofen limitierung
|
|
|
+ {
|
|
|
+
|
|
|
+ //System.out.println("dbg1");
|
|
|
+ BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
|
|
|
+
|
|
|
+
|
|
|
+ //System.out.println("dbg2");
|
|
|
+
|
|
|
+ //System.out.print()
|
|
|
+ PrintStream fo = new PrintStream(new FileOutputStream(new File("palindrom.txt")));
|
|
|
+ System.out.print("Bitte Wort 1 eingeben :");
|
|
|
+ String line = kb.readLine();
|
|
|
+ while(line!=null)
|
|
|
+ {
|
|
|
+ String line2 = "";
|
|
|
+ System.out.print("Bitte Wort 2 eingeben :");
|
|
|
+ line2 = kb.readLine();
|
|
|
+
|
|
|
+
|
|
|
+ String p1 = zip2(line+line2,invert(line+line2));
|
|
|
+ String p2 = zip2(line,line2)+invert(zip2(line,line2));
|
|
|
+ System.out.println(p1+"\n"+p2);
|
|
|
+ fo.println(p1+"\n"+p2);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ System.out.print("Bitte Wort 1 eingeben :");
|
|
|
+ line = kb.readLine();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public static String invert(String in)
|
|
|
+ {
|
|
|
+ return in.length()<2?in:invert(in.substring(1))+in.substring(0,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String zip2(String in1,String in2)
|
|
|
+ {
|
|
|
+ return //((in1.length()<2)&&(in2.length()<2))?in1+in2:zip(in1.substring(1),in2.substring(1));
|
|
|
+ in1.length()<2?
|
|
|
+ in1+in2:
|
|
|
+ in2.length()<2?
|
|
|
+ in1.substring(0,1)+in2+in1.substring(1):
|
|
|
+ in1.substring(0,1)+in2.substring(0,1)+zip2(in1.substring(1),in2.substring(1));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|