Program n1;type z = array of integer;var a: z;i,n,j,buf,t: integer;f: text;beginassign(f,'input.txt');reset(f);n:=1;t:=0;while true dobeginreadln(f,t);if(t<>0) thenbeginsetlength(a,n);a[n-1]:=t;end else break;n:=n+1;end;close(f);for i:=0 to n-3 dofor j:=i+1 to n-2 doif a[i]>a[j] then beginbuf:=a[i];a[i]:=a[j];a[j]:=buf;end;
Это наверное?