Add README.md
[pdp8.git] / sw / src / pascal / PERMUT.V2
1 PROGRAM PERMUTATIONEN(INPUT,OUTPUT);
2
3 VAR I,N: INTEGER;
4 C: ARRAY[1..10] OF INTEGER;
5
6
7
8 PROCEDURE WRITEPERMUTATION;
9 VAR I: INTEGER;
10 BEGIN
11 WRITE(" ":10);
12 FOR I := 1 TO N DO WRITE( C[I] :3);
13 WRITELN
14 END (* WRITEPERMUTATION *);
15
16
17
18 PROCEDURE PERM(K: INTEGER);
19 VAR I,H: INTEGER;
20 BEGIN
21 IF K=1 THEN WRITEPERMUTATION ELSE
22 BEGIN PERM(K-1);
23 FOR I:= 1 TO K-1 DO
24 BEGIN H := C[I]; C[I] := C[K]; C[K] := H;
25 PERM(K-1);
26 H := C[I]; C[I] := C[K]; C[K] := H
27 END
28 END
29 END (* PERM *);
30
31
32
33 BEGIN
34 WRITE("P E R M U T A T I O N E N DER ORDNUNG");
35 READ(N);
36 WRITELN;
37 FOR I := 1 TO N DO C[I] := I;
38 PERM(N)
39 END.