home *** CD-ROM | disk | FTP | other *** search
-
-
- { --> 176}
- procedure {bubble} sort(var a: ary; n: integer);
- { adapted from 'Introduction to PASCAL',
- R.Zaks, Sybex, 1980 }
-
- var no_change : boolean;
- j : integer;
-
- procedure swap(p,q: real);
- var hold : real;
- begin
- hold:=p;
- p:=q;
- q:=hold
- end; { swap }
-
- begin { procedure sort }
- repeat
- no_change:=true;
- for j:=1 to n-1 do
- begin
- if a[j]>a[j+1] then
- begin
- swap(a[j],a[j+1]);
- no_change:=false
- end
- end { for }
- until no_change
- end; { procedure sort }
-
-