DataMuseum.dk

Presents historical artifacts from the history of:

Bogika Butler

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

See our Wiki for more about Bogika Butler

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦7ede59b81⟧ TextFile

    Length: 1536 (0x600)
    Types: TextFile
    Names: »NAVNSORT.PAS«

Derivation

└─⟦f983c2ef3⟧ Bits:30004681 Pascal opgaver (Butler)
    └─ ⟦this⟧ »NAVNSORT.PAS« 

TextFile

PROGRAM navnsort;

  CONST
    antal = 10;
    maxtegn = 30;
    
  TYPE
    streng = STRING(.maxtegn.);
    arr = ARRAY(.1 .. antal.) OF streng;
  
  VAR
    tabel : arr;
  
  PROCEDURE ind(VAR tab : arr);
    
    VAR
      i : INTEGER;
    
    BEGIN (* ind *)
      WRITE(CLRHOM);
      WRITELN('Indtast ', antal, ' navne:');
      WRITELN;
      FOR i := 1 TO antal DO
        BEGIN
          WRITE('Navn nr. ', i : 3, ':  ');
          BUFLEN := maxtegn;
          READLN(tab(.i.));
        END;
    END; (* ind *)
  
  
  PROCEDURE ud(tab : arr);
  
    VAR
      i : INTEGER;
    
    BEGIN (* ud *)
      WRITELN;
      WRITELN('Navnene i alfabetisk rækkefølge:');
      WRITELN;
      FOR i := 1 TO antal DO
        WRITELN(i : 3, '  ', tab(.i.));
    END; (* ud *)
  
  PROCEDURE sortering(VAR t : arr);
    
    VAR
      i, j : INTEGER;
      navn : streng;
      slut : BOOLEAN;
    
    BEGIN (* sortering *)
      i := antal;
      REPEAT
        i := i - 1;
        slut := TRUE;
        FOR j := 1 TO i DO
          IF t(.j.) > t(.j + 1.)
            THEN
              BEGIN
                slut := FALSE;
                navn := t(.j.);
                t(.j.) := t(.j + 1.);
                t(.j + 1.) := navn;
              END;
      UNTIL (i = 1) OR slut;
    END; (* sortering *)
  
  BEGIN (* navnsort *)
    ind(tabel);
    sortering(tabel);
    ud(tabel);
  END. (* navnsort *)
«eof»