const name_len = 11; phone_len = 9; type TPE = record Name : string[name_len]; Phone : string[phone_len]; end; TPEa = array [1..20] of TPE; Procedure Exchange(var a,b:TPE); var t:tpe; begin t:=a;a:=b;b:=t; end;{Exchange} {----------------------------------------} Procedure QSort(var aA:TPEa;L,R:word); var i,j : word; cen : string[phone_len]; begin if L<>R then begin cen:=aA[(l+r) div 2].Phone; i:=l; j:=r; while i<=j do begin while (i cen) do inc(i); while (j>l) and (aa[j].Phone < cen) do dec(j); if i L then QSort(Aa,L,j); if i < r then QSort(aA,i,r); end; end;{SortNum} {----------------------------------------} var Ar : TPEa; INP : text; i,cnt : integer; begin Assign(INP,'phones.txt'); Assign(Output,'out6.txt'); Rewrite(Output); {$I-} Reset(INP); If IOResult <> 0 then begin WriteLn('File ''phones.txt'' not found'); Halt(255); end; {$I+} cnt:=1; While not EOF(INP) do begin Read(INP,Ar[cnt].Name); ReadLn(INP,Ar[cnt].Phone); WriteLn(Ar[cnt].Name,Ar[cnt].Phone); inc(cnt); end; Close(INP); WriteLn('Result:'); Dec(cnt); QSort(Ar,1,cnt); for i := 1 to cnt do WriteLn(Ar[i].Name,Ar[i].Phone); WriteLn('End.'); end.