Berechnen der Route II

 [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

SantaClaus.m2
BEGIN (* ComputeRoute *)
   FOR location := 0 TO noflocations-1 DO
      visited[location] := FALSE;
   END;
   length := 0; (* bislang noch nicht vorangekommen *)
   location := 0; (* Startpunkt der Reise *)
   nofvisits := 0;
   WHILE nofvisits < noflocations DO
      WriteLocation(location);
      visited[location] := TRUE;
      INC(nofvisits);
      IF nofvisits = noflocations THEN
         nextlocation := 0; (* und wieder zurueck *)
      ELSE
         nextlocation := NextLocation(location);
      END;
      INC(length, distances[location, nextlocation]);
      WriteString("-->"); WriteLocation(nextlocation);
      Write("[");
      WriteCard(distances[location, nextlocation], ndigits);
      Write("]"); WriteLn;
      location := nextlocation;
   END;
   WriteString("Insgesamt zurueckgelegt: ");
   WriteCard(length, 1); WriteLn;
END ComputeRoute;

*NextLocation ermittelt jeweils entsprechend der vorgegebenen Methode den nächsten Ort.
 
*WriteLocation gibt den jeweiligen Index um eins erhöht aus (Informatiker zählen ab 0, Anwender ab 1).
 

 [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1999 Andreas Borchert, in HTML konvertiert am 13.01.1999