program spisok; uses crt; type sp=^adres; adres=record street:string; dom,kv,zilci:integer; link:sp; end; sp1=^adres1; adres1=record street:string; dom,kv,zilci:integer; link:sp1; end; var begp,endp,pp:sp; begp1,endp1:sp1; i,j:integer; nm:byte; v:boolean; Procedure vvod(var begp,endp:sp); var pp:sp; begin Writeln('vvedite kolichestvo zap'); readln(nm); for i:=1 to nm do begin new(pp); write('street '); readln(pp^.street); write('# doma '); readln(pp^.dom); write('# kvartiri '); readln(pp^.kv); write('kol-vo zilcov '); readln(pp^.zilci); pp^.link:=nil; if begp=nil then begp:=pp else endp^.link:=pp; endp:=pp; end; end; procedure vivod(begp,endp:sp); var pp:sp; begin clrscr; write('--------------------------------------------------'); writeln; write('| street | #doma | #kv | kol-vo zilcov |'); for i:=1 to nm do pp:=begp; while pp<>nil do begin writeln; write(pp^.street:12,' '); write(pp^.dom:6, ' ' ,pp^.kv:9, ' ', pp^.zilci:8, ' '); writeln; pp:=pp^.link; end; write('---------------------------------------------------'); writeln; end; procedure poisk(var begp1,endp1:sp1;begp,endp:sp); var pp:sp; pp1:sp1; begin writeln('Vvedite street, dom, kv cheres enter'); begin readln(pp1^.street); readln(pp1^.dom); readln(pp1^.kv); pp:=begp; while pp<>nil do begin if ((pp1^.street=pp^.street) and (pp1^.dom=pp^.dom)) and (pp1^.kv=pp^.kv) then begin write('Kol-vo zilcov: '); write(pp^.zilci); writeln; v:=true; end; if v=false then writeln('takogo adresa ne naideno'); pp:=pp^.link; end; end; end; procedure sort(begp,endp:sp); var pp,p1,pt:sp; t,r,g:integer; k:string; begin for i:=1 to nm do pp:=begp; while pp<>endp do begin t:=pp^.zilci; pt:=pp; p1:=pp; while p1^.link<>nil do begin p1:=p1^.link; if p1^.zilci<=pp^.zilci then begin t:=p1^.zilci; pt:=p1; end; end; pt^.zilci:=pp^.zilci; pp^.zilci:=t; pp:=pp^.link; end; end; procedure vivodsort(begp,endp:sp); var pp:sp; begin write('--------------------------------------------------'); writeln; write('| street | #doma | #kv | kol-vo zilcov |'); for i:=1 to nm do pp:=begp; while pp<>nil do begin writeln; write(pp^.street:12,' '); write(pp^.dom:6, ' ' ,pp^.kv:9, ' ', pp^.zilci:8, ' '); writeln; pp:=pp^.link; end; write('---------------------------------------------------'); writeln; end; Procedure novmas(var begp,endp:sp); var x:string; pp:sp; begin for i:=1 to nm do x:=begp^.street; pp:=begp; begp:=pp^.link; dispose(pp); end; Procedure novmasa(begp,endp:sp); var pp:sp; begin write('-------------------------------------'); writeln; write('| #doma | #kv | kol-vo zilcov |'); pp:=begp; while pp<>nil do begin writeln; write(pp^.dom:6, ' ' ,pp^.kv:8, ' ',pp^.zilci:8, ' '); writeln; pp:=pp^.link; end; write('-------------------------------------'); writeln; readln; end; begin clrscr; begp:=nil; endp:=nil; vvod(begp,endp); vivod(begp,endp); poisk(begp1,endp1,begp,endp); sort(begp,endp); writeln('ots spisok'); vivodsort(begp,endp); novmas(begp,endp); novmasa(begp,endp); readln; end.