DataMuseum.dk

Presents historical artifacts from the history of:

RegneCentralen RC700 "Piccolo"

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about RegneCentralen RC700 "Piccolo"

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦26ed308cb⟧ TextFile

    Length: 1024 (0x400)
    Types: TextFile
    Names: »RNDWALK.PAS«

Derivation

└─⟦09235ab48⟧ Bits:30003065 Demoprogrammer K-Z til Pascal bog
    └─ ⟦this⟧ »RNDWALK.PAS« 

TextFile

PROGRAM rndwalk;

  VAR
    radius, radius2, antal, sum, i, x, y, rnd : INTEGER;
  
  BEGIN
    WRITE(CLRHOM);
    WRITELN('RANDOM WALK');
    WRITELN;
    WRITE('Tast antal forsøg pr. radius: ');
    READLN(antal);
    RANDOMIZE;
    WRITELN;
    WRITELN('RADIUS', 'GENNEMSNITLIG TID' : 30);
    WRITELN;
    FOR radius := 2 TO 10 DO
      BEGIN
        radius2:= SQR(radius);
        sum := 0;
        FOR i := 1 TO antal DO
          BEGIN
            x := 0;
            y := 0;
            REPEAT
              sum := sum + 1;
              rnd := RANDOM(4);
              CASE rnd OF
                0 : x := x + 1;
                1 : y := y + 1;
                2 : x := x - 1;
                3 : y := y - 1;
              END;
            UNTIL SQR(x) + SQR(y) >= radius2;
          END;
        WRITELN(radius : 4, sum / antal : 25 : 2);
      END;
  END.
  «eof»