Miquel_Fuster

qsort - llamante

Jan 11th, 2022 (edited)
1,410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
COBOL 0.79 KB | None | 0 0
  1. IDENTIFICATION DIVISION.
  2. PROGRAM-ID. PROGRAMA.
  3. DATA DIVISION.
  4.  
  5. WORKING-STORAGE SECTION.
  6. 01 ARRAY.
  7.     05 ELEMENTO PIC 9 OCCURS 10 INDEXED BY I.
  8.  
  9. PROCEDURE DIVISION.
  10. MAIN-PROCEDURE.
  11.     PERFORM CARGAR-ARRAY.
  12.     PERFORM MOSTRAR-ARRAY.
  13.     CALL "QSORT" USING ARRAY, 1, 10.
  14.     PERFORM MOSTRAR-ARRAY.
  15.     STOP RUN.
  16.    
  17. CARGAR-ARRAY.
  18.     MOVE 5 TO ELEMENTO(1).
  19.     MOVE 7 TO ELEMENTO(2).
  20.     MOVE 2 TO ELEMENTO(3).
  21.     MOVE 8 TO ELEMENTO(4).
  22.     MOVE 3 TO ELEMENTO(5).
  23.     MOVE 0 TO ELEMENTO(6).
  24.     MOVE 4 TO ELEMENTO(7).
  25.     MOVE 9 TO ELEMENTO(8).
  26.     MOVE 1 TO ELEMENTO(9).
  27.     MOVE 6 TO ELEMENTO(10).
  28.    
  29. MOSTRAR-ARRAY.
  30.     PERFORM VARYING I FROM 1 BY 1 UNTIL I > 10
  31.         DISPLAY ELEMENTO(I) ' ' WITH NO ADVANCING
  32.     END-PERFORM.
  33.     DISPLAY ' '.
  34.  
  35. END PROGRAM PROGRAMA.
  36.  
Add Comment
Please, Sign In to add comment