DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

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

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦398522a4c⟧ TextFile

    Length: 1408 (0x580)
    Types: TextFile
    Names: »BUBBLE2.PAS«

Derivation

└─⟦092727b26⟧ Bits:30005927 Demoprogrammer til Pascal bog (Jet-80)
    └─ ⟦this⟧ »BUBBLE2.PAS« 
└─⟦3702e543b⟧ Bits:30003064 Demoprogrammer A-J til Pascal bog
    └─ ⟦this⟧ »BUBBLE2.PAS« 
└─⟦f983c2ef3⟧ Bits:30004681 Pascal opgaver (Butler)
    └─ ⟦this⟧ »BUBBLE2.PAS« 

TextFile

        PROGRAM bubble2;
        
        (* Programmet sorterer en række tal ved bubblesort-metoden *)
        (* Udskriften kommer på printeren                          *)
        
        CONST
          max = 150;
        
        TYPE
          vektor = ARRAY(.1 .. max.) OF INTEGER;
        
        VAR
          v : vektor;
          i, j, byt : INTEGER;
        
        BEGIN
          RANDOMIZE;
          FOR i := 1 TO max DO  (* Vi finder først nogle tal *)
            v(.i.) := RANDOM(200);
          WRITELN(LST,CHR(12),'De usorterede tal er:');
          FOR i := 1 TO max DO
            BEGIN
              WRITE(LST,v(.i.):4);
              IF i MOD 20 = 0
                THEN WRITELN(LST);
            END;
          WRITELN(LST);
          FOR i := max - 1 DOWNTO 1 DO (* Tallene sorteres *)
            FOR j := 1 TO i DO
              IF v(.j.) > v(.j + 1.)
                THEN
                  BEGIN
                    byt := v(.j.);
                    v(.j.) := v(.j + 1.);
                    v(.j + 1.) := byt;
                  END;
          WRITELN(LST);
          WRITELN(LST,'De sorterede tal er:');
          FOR i := 1 TO max DO
            BEGIN
              WRITE(LST,v(.i.):4);
              IF i MOD 20 = 0
                THEN WRITELN(LST);
              END;
          WRITELN(LST);
        END.
«eof»