PROGRAM PERMUTATIONEN(INPUT,OUTPUT);

    VAR I,N: INTEGER;
        C: ARRAY[1..10] OF INTEGER;



    PROCEDURE WRITEPERMUTATION;
      VAR I: INTEGER;
        BEGIN
            WRITE(" ":10);
            FOR I := 1 TO N  DO WRITE( C[I] :3);
            WRITELN
        END (* WRITEPERMUTATION *);



    PROCEDURE PERM(K: INTEGER);
      VAR I,H: INTEGER;
        BEGIN
            IF K=1 THEN WRITEPERMUTATION ELSE
            BEGIN PERM(K-1);
                FOR I:= 1 TO K-1 DO
                BEGIN H := C[I]; C[I] := C[K]; C[K] := H;
                      PERM(K-1);
                      H := C[I]; C[I] := C[K]; C[K] := H
                END
            END
        END (* PERM *);



BEGIN
    WRITE("P E R M U T A T I O N E N   DER ORDNUNG");
    READ(N);
    WRITELN;
    FOR I := 1 TO N DO C[I] := I;
    PERM(N)
END.
