Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- plik powinien sie nazywac hello.adb
- -- kompilacja: gnatmake <plik>
- with Ada.Text_IO; use Ada.Text_IO;
- procedure Hello is
- type Tablica is array(integer range<>) of Integer;
- procedure sort(tab: in out Tablica) is
- shouldEnd: Boolean := false;
- procedure swap(x,y: in out Integer) is t: Integer; begin t := x;x := y;y := t;end;
- begin
- while not shouldEnd loop
- shouldEnd := true;
- for i in tab'first .. tab'last -1 loop
- if tab(i) > tab(i+1) then
- swap(tab(i),tab(i+1));
- shouldEnd := false;
- end if;
- end loop;
- end loop;
- end;
- shouldEnd: Boolean := false;
- tab: Tablica(1..10) := (3,5,1,7,8,4,9,10,2,6);
- tab2: array(1..10) of Integer := (3,5,others => 9);
- begin
- for i in tab'range loop
- Put_line(Integer'image(tab(i)));
- end loop;
- Put_line("---- SORTING ----");
- sort(tab);
- for i in tab'range loop
- Put_line(Integer'image(tab(i)));
- end loop;
- end Hello;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement