Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var a: array of integer := (20, 18, 7, 4, 5, 14, 6, 1, 12, 9);
- procedure BubbleSort;
- var
- flag: boolean;
- x: integer;
- begin
- for var i := 0 to a.Length - 1 do
- begin
- flag := true;
- for var j := a.Length - 2 downto i do
- if a[j] > a[j + 1] then
- begin
- flag := false;
- x := a[j];
- a[j] := a[j + 1];
- a[j + 1] := x;
- end;
- if flag then break;
- end;
- end;
- begin
- writeln(a);
- BubbleSort();
- writeln(a);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement