Path: utzoo!utgpu!news-server.csri.toronto.edu!torsqnt!tmsoft!masnet!rose!andy.tam From: andy.tam@rose.uucp (ANDY TAM) Newsgroups: comp.lang.pascal Distribution: world Subject: Combsort problem Message-ID: Date: Thu, 2 May 91 5:22:00 EST Organization: Rose Media, ON, CANADA Lines: 39 AL>From: alex@aureus.sublink.org (Sandro Doro) AL>Orga: Sublink network site, Venice - Italy AL> procedure comb(var x: arraytype; AL> n: aptr); AL> var AL> i,j,gap: aptr; AL> intchange: boolean; AL> hold: tdata; AL> begin AL> intchange:=true; AL> gap:=n; AL> repeat AL> gap:=trunc(gap*1.0/shrinkFactor); AL> if gap<1 then gap:=1; AL> intchange:=false; AL> for j:=1 to n-gap do AL> begin AL> i:=j+gap; AL> if x[j]>x[i] then AL> begin AL> intchange:=true; AL> hold:=x[j]; AL> x[j]:=x[i]; AL> x[i]:=hold AL> end AL> end AL> until (gap=1) and (intchange) AL> end; the UNTIL line should be : until (gap = 1) and (not intchange) ---