Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Lukas on 22.04.2017.
- */
- public class Main {
- private static String lastStep = "int_LS";
- private static String notAllowed = "init_NA";
- private static int count = 0; //soll Anzahl der besuchten Punkte zählen
- private static int n;
- //besuchte Punkte = Anzahl der "Linien" + Anzahl der Möglichen Pfade ?!
- public static void main(String[] args) {
- n = 5;
- pfadeZeichnen();
- }
- private static void pfadeZeichnen() {
- int x = 0;
- int y = 0;
- while (x != n && y != n) {
- if (y >= x) { // ↑ ist nur erlaubt, wenn der Startpunkt auf oder oberhalb der Diagonalen liegt
- // ↑
- y = y + 1;
- System.out.println("Oben");
- }
- if (true) { //sinnlose bedingung nur zur übersicht
- // ↗ immer erlaubt
- x = x + 1;
- y = y + 1;
- System.out.println("Rechts Oben");
- }
- if (lastStep != notAllowed) { //↖↘ oder ↘↖ NICHT in einer Folge direkt hintereinander
- // ↖
- x = x - 1;
- y = y + 1;
- lastStep = "LinksOben";
- notAllowed = "RechtsUnten";
- System.out.println("Links Oben");
- }
- if (lastStep != notAllowed) { //↖↘ oder ↘↖ NICHT in einer Folge direkt hintereinander.
- // ↘
- x = x + 1;
- y = y - 1;
- lastStep = "RechtsUnten";
- notAllowed = "LinksOben";
- System.out.println("Rechts Unten");
- }
- }
- if (y <= x) { //→ ist nur erlaubt, wenn der Startpunkt auf oder unterhalb der Diagonalen liegt
- x = x + 1; // →
- System.out.println("Rechts");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement