Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. /**
  2.  * Created by Lukas on 22.04.2017.
  3.  */
  4. public class Main {
  5.  
  6.   private static String lastStep = "int_LS";
  7.   private static String notAllowed = "init_NA";
  8.  
  9.   private static int count = 0; //soll Anzahl der besuchten Punkte zählen
  10.   private static int n;
  11.  
  12.   //besuchte Punkte = Anzahl der "Linien" + Anzahl der Möglichen Pfade ?!
  13.  
  14.  
  15.   public static void main(String[] args) {
  16.  
  17.     n = 5;
  18.     pfadeZeichnen();
  19.   }
  20.  
  21.   private static void pfadeZeichnen() {
  22.  
  23.     int x = 0;
  24.     int y = 0;
  25.  
  26.     while (x != n && y != n) {
  27.  
  28.       if (y >= x) { // ↑ ist nur erlaubt, wenn der Startpunkt auf oder oberhalb der Diagonalen liegt
  29.         // ↑
  30.         y = y + 1;
  31.         System.out.println("Oben");
  32.       }
  33.  
  34.       if (true) { //sinnlose bedingung nur zur übersicht
  35.         // ↗ immer erlaubt
  36.         x = x + 1;
  37.         y = y + 1;
  38.         System.out.println("Rechts Oben");
  39.       }
  40.  
  41.       if (lastStep != notAllowed) { //↖↘ oder ↘↖ NICHT in einer Folge direkt hintereinander
  42.         // ↖
  43.         x = x - 1;
  44.         y = y + 1;
  45.  
  46.         lastStep = "LinksOben";
  47.         notAllowed = "RechtsUnten";
  48.  
  49.         System.out.println("Links Oben");
  50.       }
  51.  
  52.       if (lastStep != notAllowed) { //↖↘ oder ↘↖ NICHT in einer Folge direkt hintereinander.
  53.         // ↘
  54.         x = x + 1;
  55.         y = y - 1;
  56.  
  57.         lastStep = "RechtsUnten";
  58.         notAllowed = "LinksOben";
  59.  
  60.         System.out.println("Rechts Unten");
  61.       }
  62.  
  63.  
  64.     }
  65.  
  66.     if (y <= x) { //→ ist nur erlaubt, wenn der Startpunkt auf oder unterhalb der Diagonalen liegt
  67.  
  68.       x = x + 1; // →
  69.       System.out.println("Rechts");
  70.  
  71.     }
  72.   }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement