Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Chains {
- public static void main (String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Bitte wählen Sie zunächst, welche Zeichenkette sie bilden wollen und geben Sie anschließend die Ordnung oder die Länge der Kette an. ");
- System.out.println("| C für Charchain | \t D für Dragonchain | \t L für LevyC ");
- String userinput = input.nextLine();
- if(userinput.equals("C")) {
- charChain(int k);
- } else if(userinput.equals("D")) {
- dragonChain(int k);
- } else if(userinput.equals(int k)) {
- levyC(int k);
- } else {
- System.out.println("Fehler bei Eingabe: Ungültiger Aufruf");
- }
- }
- public static void charChain(int k) {
- if(k > 0 || k <= 100000) {
- char[] chars = new char[];
- char chars[] = {'F','R','L'};
- System.out.printf("Laenge k der Zeichenkette: %c\n", k);
- for(int i = 0; i < chars.length; i++) {
- System.out.printf("%c", chars[StdRandom.uniform[3]]);
- }
- } else {
- System.out.println("Fehler: Die Laenge k der Zeichenkette darf nur zwischen 0 und 100001 liegen.");
- }
- }
- public static void dragonChain(int k) {
- if(k > 20 && k < 0) {
- int length = (int) Math.pow(2,k + 1) - 1;
- char[] dragon = new char[length];
- dragon[0] = 'F';
- System.out.print(dragon[0]);
- for(int i = 1; i < length; i++) {
- if(dragon[i - 1] == 'F')
- int random = StdRandom.uniform(2);
- if(dragon[i] == 0) {
- dragon[i] = 'R';
- } else {
- dragon[i] = 'L';
- }
- }else {
- dragon[i] = 'F';
- }
- } else {
- System.out.println("Fehler");
- }
- for(int i = 1; i < length; i++){
- System.out.printf("%c", dragon);
- }
- System.out.println("Die Länge der Zeichenkette ist:" + length);
- }
- public static void levyC(int k) {
- if(k > 20 && k < 0) {
- char[] levy = new char[];
- char levy[] = {'F','+','-'};
- for(int = 0; i <= k; i++) {
- if(i == 0) {
- levy[0] = 'F';
- } else {
- hilfsMethodeL(char[] levy);
- }
- }
- } else{
- System.out.println("Fehler");
- }
- }
- public static void hilfsMethode(int i) {
- if(i == 0){
- return "i";
- } else {
- return;
- }
- }
- public static void hilfLevyC (char[] levy){
- char[] levyH = new char[2 * levy.length + 4];
- levyH[0] = '+';
- for(int j = 1; j <= levyH.length; j++) {
- for(int i = 0; i <= levy.length; i++) {
- levyH[j] = levy[i];
- }
- levyH[levy.length + 1] = '-';
- levyH[levy.length + 2] = '-';
- }
- levyH[0] = '+';
- }
- public static void umwandeln(char[] levy) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement