Browse Source

aufgaben gesichert

git-svn-id: http://repo.nplusc.de/svn/iZink@160 8b19561d-0d00-6744-8ac1-9afc8f58a8aa
masterX244 11 years ago
parent
commit
01bd6b9cd0

BIN
HHN/%C3%9C2/src/Filecopy.class


+ 53 - 0
HHN/%C3%9C2/src/Filecopy.java

@@ -0,0 +1,53 @@
+
+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 Filecopy
+{
+        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()
+        System.out.print("Bitte Quelldateinamen eingeben:");
+        String line = kb.readLine();
+        while(line!=null)
+        {
+            BufferedReader fi = new BufferedReader(new InputStreamReader(new FileInputStream(new File(line))));
+            System.out.print("Bitte Zieldateinamen eingeben:");
+            line = kb.readLine();
+            PrintStream fo = new PrintStream(new FileOutputStream(new File(line)));
+            String line2 = fi.readLine();
+            while(line2!=null)
+            {
+                fo.println(line2);
+                line2 = fi.readLine();
+            }
+            
+            
+            
+            
+            
+            System.out.print("Bitte Quelldateinamen eingeben:");
+            line = kb.readLine();
+        }
+    }
+}

+ 50 - 0
HHN/%C3%9C2/src/Filter.java

@@ -0,0 +1,50 @@
+import java.net.*;
+import java.io.*;
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+class Filter{
+	public static void main(String[] args) throws Exception{
+		InputStreamReader isr;
+        BufferedReader userInput;
+        String textInput;
+		String searchword;
+		
+		/** Benutzereingabe */
+        isr = new InputStreamReader(System.in);
+        userInput = new BufferedReader(isr);
+		System.out.println("Geben Sie einen URL ein: ");
+		textInput = userInput.readLine();
+		System.out.println("Geben Sie den Suchtext ein");
+		searchword = userInput.readLine();
+		
+		/** 
+		 * 1. Neuen Url anlegen 
+		 * 2. Url als Stream öffnen und nach FilterInputStream casten
+		 * 3. FilterInputStream -> BufferedReader
+		 */
+		URL u = new URL(textInput);
+		FilterInputStream ins = (FilterInputStream) u.openStream();
+		InputStreamReader ir = new InputStreamReader(ins);
+		BufferedReader site= new BufferedReader(ir);
+		
+		/** Lesen der ersten Zeile im Fall von null */
+		String line = site.readLine();
+		
+		/** Restliche Zeilen einlesen und bei enthaltenem Suchstring ausgeben */
+		while(line != null){
+			System.out.print(line.contains(searchword)?line+"\n":"");
+			line=site.readLine();
+
+		}
+
+	}
+
+	
+}

+ 32 - 0
HHN/%C3%9C2/src/Ggt.java

@@ -0,0 +1,32 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+public class Ggt
+{
+    public static void main(String[] args) throws Exception
+    {
+        InteractiveIO i = new InteractiveIO();
+        int x = 5;//Integer.parseInt(i.promptAndRead("Zahl 1"));
+        int y =5;// Integer.parseInt(i.promptAndRead("Zahl 2"));
+        System.out.println(calculateGGTcheck(x,y));
+    }
+    
+            private static int calculateGGTcheck(int x,int y)
+        {
+            return y==0?0:calculateGGT(x,y);
+        }
+    
+    
+    private static int calculateGGT(int x, int y)
+    {
+        int rest = x%y;
+        return rest==0?y:calculateGGT(y, rest);
+    }
+    
+}

+ 37 - 0
HHN/%C3%9C2/src/GgtMit.java

@@ -0,0 +1,37 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+public class GgtMit
+{
+        public static void main(String[] args) throws Exception
+    {
+        InteractiveIO iio = new InteractiveIO();
+        int x = Integer.parseInt(iio.promptAndRead("Zahl 1"));
+        int y = Integer.parseInt(iio.promptAndRead("Zahl 2"));
+        int i = 0;
+        while (i<=100)
+        {
+            System.out.println(calculateGGTcheck(x+i,y));
+            i++;
+        }
+    }
+    
+        
+        private static int calculateGGTcheck(int x,int y)
+        {
+            return y==0?0:calculateGGT(x,y);
+        }
+        
+        
+    private static int calculateGGT(int x, int y)
+    {
+        int rest = x%y;
+        return rest==0?y:calculateGGT(y, rest);
+    }
+}

+ 40 - 0
HHN/%C3%9C2/src/InteractiveIO.java

@@ -0,0 +1,40 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+import java.io.*;
+
+class InteractiveIO
+{
+
+    private BufferedReader br;
+
+    public InteractiveIO()
+    {
+        br = new BufferedReader(new InputStreamReader(
+                System.in));
+    }
+
+    public void write(String s)
+    {
+        this.writeAndFlush(s);
+    }
+
+    public String promptAndRead(String s) throws
+            Exception
+    {
+        this.writeAndFlush(s);
+        return br.readLine();
+    }
+
+    private void writeAndFlush(String s)
+    {
+        System.out.println(s);
+        System.out.flush();
+    }
+}

BIN
HHN/%C3%9C2/src/Janus.class


+ 34 - 0
HHN/%C3%9C2/src/Janus.java

@@ -0,0 +1,34 @@
+
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+public class Janus
+{
+    public static void main(String[] args) throws Exception //unfein; amchs nur wegen ihrer doofen limitierung
+    {
+        
+        //System.out.println("dbg1");
+        BufferedReader fr = new BufferedReader(new InputStreamReader(new FileInputStream(new File("Janus.java"))));
+        //System.out.println("dbg2");
+        
+        //System.out.print()
+        String line = fr.readLine();
+        while(line!=null)
+        {
+            System.out.println(line);
+            line = fr.readLine();
+        }
+    }
+}

BIN
HHN/%C3%9C2/src/Palindromgenerator.class


+ 71 - 0
HHN/%C3%9C2/src/Palindromgenerator.java

@@ -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));
+                        
+    }
+        
+}

BIN
HHN/%C3%9C2/src/Palindromtest.class


+ 41 - 0
HHN/%C3%9C2/src/Palindromtest.java

@@ -0,0 +1,41 @@
+
+import static de.nplusc.hhn.ZipInvert.invert;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+public class Palindromtest
+{
+    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()
+        System.out.print("Bitte Wort eingeben :");
+        String line = kb.readLine();
+        while(line!=null)
+        {
+            String rslt = (line.equals(invert(line))?"":"Kein ")+"Palindrom";
+            System.out.println(rslt);
+            line = kb.readLine();
+        }
+    }
+    
+        public static String invert(String in)
+    {
+        return in.length()<2?in:invert(in.substring(1))+in.substring(0,1);
+    }
+}

+ 34 - 0
HHN/%C3%9C2/src/Person.java

@@ -0,0 +1,34 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+public class Person
+{
+    public static InteractiveIO iio = new InteractiveIO();
+    private String name,beruf,lieblingsfarbe,lieblingstier;
+
+    public Person() throws Exception
+    {
+        this.name = iio.promptAndRead("Name:");
+        this.beruf = iio.promptAndRead("Beruf:");
+        this.lieblingsfarbe = iio.promptAndRead("Lieblingsfarbe:");
+        this.lieblingstier = iio.promptAndRead("Lieblingstier:");
+    }
+    
+    public String toString()
+    {
+        return "Name: "+name+"\n"+
+               "Beruf: "+beruf+"\n"+
+               "Lieblingsfarbe: "+lieblingsfarbe+"\n"+
+               "Lieblingstier: "+lieblingstier;
+        
+        
+    }
+    
+    
+}

BIN
HHN/%C3%9C2/src/ShiftAll.class


+ 45 - 0
HHN/%C3%9C2/src/ShiftAll.java

@@ -0,0 +1,45 @@
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+public class ShiftAll
+{
+    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()
+        System.out.print("Bitte einen Text eingeben:");
+        String line = kb.readLine();
+        while(line!=null)
+        {
+            int shiftmax = line.length();
+            int i = 0;
+            while(i<=shiftmax)
+            {
+                System.out.println(line);
+                line = shift(line);
+                i=i+1; //i++
+            }
+            System.out.print("Bitte einen Text eingeben:");
+            line = kb.readLine();
+        }
+    }
+    
+    public static String shift(String in)
+    {
+        return in.length() < 2 ? in : in.substring(1) + in.substring(0, 1);
+    }
+}

+ 16 - 0
HHN/%C3%9C2/src/Tstst.java

@@ -0,0 +1,16 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author LH
+ */
+public class Tstst
+{
+    public static void Main(String[] args)
+    {
+        
+    }
+}

+ 2 - 0
HHN/%C3%9C2/src/de/nplusc/hhn/Dopple.java

@@ -22,3 +22,5 @@ public class Dopple
     }
     
 }
+
+

+ 51 - 0
HHN/%C3%9C2/src/de/nplusc/hhn/TzTest.java

@@ -0,0 +1,51 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package de.nplusc.hhn;
+
+/**
+ *
+ * @author LH
+ */
+class TzTest
+{
+ public static void main(String[] args)
+ {
+ String a = "123";
+ String b = "4569";
+ String c = "78922"; 
+ 
+ String smallest;
+ String greatest;
+ String medium;
+  
+ smallest = (a.length() < b.length()) ? (c.length() < a.length()) ?
+ c : a : b;
+ 
+ greatest = (a.length() > b.length()) ?
+                    (c.length() > a.length())?
+                                            c :
+                            b:
+                        a; 
+ 
+ 
+ medium = (a.length() < b.length()) ? (c.length() < a.length()) ?
+ a : b : c;
+
+ System.out.println(smallest);
+ System.out.println(medium);
+ System.out.println(greatest);
+ //System.out.println(zipIt(smallest, medium, greatest));
+    }
+   
+   
+   public static String zipIt(String aa, String bb, String cc)
+ {
+  return (aa.length() == 1) ? aa + bb + cc :
+         aa.substring(0,1) + bb.substring(0,1) + cc.substring(0,1) +
+         zipIt(aa.substring(1), bb.substring(1), cc.substring(1));
+         
+         
+ }
+}

BIN
HHN/%C3%9C2/src/de/nplusc/hhn/Zip.class


BIN
HHN/%C3%9C2/src/de/nplusc/hhn/ZipInvert.class


+ 2 - 0
HHN/%C3%9C2/src/palindrom.txt

@@ -0,0 +1,2 @@
+1827364554637281
+1526374884736251