{1ая - Вставками по индексам ******************************************} Procedure Sort1 (FileName:string); var i,j : Integer; st_i, st_j : prokat; f1 : File of prokat; x : word; Procedure get_element_by_index(i:word; Var st:prokat); begin seek(f1,i); read(f1,st); end; begin Assign(f1, FileName); Reset(f1); for i := 0 to filesize(f1)-1 do Mas[i] := i; For i := 1 to filesize(f1)-1 do begin get_element_by_index(Mas[i],st_i); j := i-1; get_element_by_index(Mas[j],st_j); x := mas[i]; While ((st_i.city=0) then break; get_element_by_index(Mas[j],st_j); end; mas[j+1] := x; end; close(f1); end; Procedure printAnotherCity; Procedure GetMasWithoutStuff (filename : string); Var i,j : word; f : file of prokat; st : prokat; begin Assign(f,filename); reset(f); j := 0; For i := 0 to filesize(f)-1 do begin Seek (f,mas[i]); Read (f,st ); If st.City <> OurCity then begin MasWOstuff[j] := mas[i]; inc(j); end; end; SizeMWOS := j; close(f); end; begin Sort1 (wfileName); GetMasWithOutStuff (wfilename ); SuperPrint (wfileName); end; {end 1} {2ая - Челночная сортировка ***********************} Procedure Sort2 (FileName : String); Var f : File of prokat; i, Num_Move : word; Procedure Move; Var pac1, Pac2 :prokat; x : word; Begin Seek (f, mas[i-1]); Read (f, Pac1); Seek (f, mas[i]); Read (f, Pac2); if (Pac1.diagnoz > Pac2.diagnoz) or ((Pac1.diagnoz = Pac2.diagnoz) and (Pac1.Sname_patienta > Pac2.Sname_patienta )) then Begin {условие, при котором меняются местами Пациенты Pac1 и Pac2} x := mas[i-1]; Mas[i-1] := mas[i]; mas[i] := x; Inc(num_Move); end; end; Begin Assign (f, FileName); Reset (f); For i := 0 to filesize(f)-1 do Mas[i] := i; While true do Begin num_Move:=0; For i := 1 to Filesize(f)-1 do Move; If Num_Move = 0 then Break; num_Move:=0; For i := Filesize(f)-1 downto 1 do Move; If Num_Move = 0 then Break; end; Close(f); end; Procedure printAgesDiagnos; Var k, num : Word; Procedure GetMasWithoutStuff2 (filename : string); Var i,j : word; f : file of prokat; st : prokat; begin Clrscr; Write('Введите возраст: '); Readln(min_age); Assign(f,filename); reset(f); j := 0; For i := 0 to filesize(f)-1 do begin Seek (f,mas[i]); Read (f,st ); If st.age > min_age then begin MasWOstuff[j] := mas[i]; inc(j); end; end; SizeMWOS := j; close(f); end; begin Sort2 (wfilename); GetMasWithoutstuff2 (wfilename); SuperPrint (wFileName); end; {end 2}