Advertisement
Guest User

Untitled

a guest
May 30th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.71 KB | None | 0 0
  1. with Ada.Text_IO; use Ada.Text_IO;
  2.  
  3. procedure Hello is
  4.  
  5. procedure swap(x, y: in out Integer) is
  6. tmp: Integer;
  7. begin
  8.     tmp := x;
  9.     x := y;
  10.     y := tmp;
  11. end swap;
  12.  
  13.  
  14. type Tablica is array(Integer range <>) of Integer;
  15. procedure Sort (tab: in out Tablica) is
  16. begin
  17. for j in tab'first..tab'last-1 loop
  18.         for i in tab'first..tab'last-1 loop
  19.             if tab(i) > tab(i+1) then
  20.                 swap(tab(i), tab(i+1));
  21.             end if;
  22.         end loop;
  23.     end loop;
  24.  
  25.     for i in tab'first..tab'last-1 loop
  26.             Put_Line (Integer'Image (tab(i)));
  27.     end loop;
  28. end Sort;
  29.  
  30. tab: Tablica(1..10) := (3, 5, 1, 7, 0, 3, 5, 1, 7, 0);
  31. temp: Integer;
  32.  
  33. begin
  34.     Sort(tab);    
  35. end Hello;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement