Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODULE bubble_sort;
- VAR
- n, i, j, temp: integer;
- a: array 1000 of integer;
- BEGIN
- read(n);
- i := 0;
- while i < n do
- read(a[i]);
- i := i + 1;
- end;
- i := 1;
- while i <= n - 1 do
- j := 0;
- while j < n - i do
- if a[j] > a[j + 1] then begin
- temp := a[j];
- a[j] := a[j + 1];
- a[j + 1] := temp;
- end;
- j := j + 1;
- end;
- i := i + 1;
- end;
- i := 0;
- while i < n do
- write(a[i]);
- i := i + 1;
- end;
- writeln();
- END bubble_sort.
Add Comment
Please, Sign In to add comment