'begin' 'comment' simple sorting of an array. the rand function gives always the same sequence... ; 'integer' NN; 'real' seed; 'real' 'procedure' rand; 'begin' seed := seed * 1.56754673456; rand := seed := seed - entier (seed); 'end'; 'procedure' dosort (arr) len: (nn); 'value' nn; 'integer' 'array' arr; 'integer' nn; 'begin' 'procedure' swap (x, y); 'begin' 'integer' xx; xx := x; x := y; y := xx; 'end'; 'integer' i, j; 'for' i:=1 'step' 1 'until' nn-1 'do' 'begin' 'for' j:=i 'step' -1 'until' 1 'do' 'begin' 'if' arr [j] > arr [j+1] 'then' swap (arr[j], arr[j+1]); 'end'; 'end'; 'end'; NN := 20; seed := 0.5; 'begin' 'integer' 'array' ii [1 : NN]; 'integer' i; outstring (1, "simple sorting:\n"); 'for' i := 1 'step' 1 'until' NN 'do' 'begin' ii [i] := entier (rand * NN); outinteger (1, ii[i]); 'end'; outstring (1, "\n"); dosort (ii, NN); outstring (1, "result:\n"); 'for' i := 1 'step' 1 'until' NN 'do' outinteger (1, ii[i]); outstring (1, "\ndone.\n") 'end'; 'end'