var a: integer; b: integer absolute a; P: array[1..25,1..80] of record znak: char; barva: byte end absolute $b800:0000; tick: longint absolute 0:$46c; start: longint; begin a := 5; write( b ); start := tick; readln; writeln( (tick-start)/18.2 * 1000 :5,' ms' ); Mem[ 1234:7890 ] := 255 end. procedure Tiskni( s: string ); begin if s='' then write('.') else begin Tiskni( copy(s,2,length(s)) ); write( s[1] ) end end; begin Tiskni( 'abcdefgh' ); Tiskni( '111111111111111111111111111111111111111111222222222222222222222222222222222222222333333333333333333333333333444' ); end. uses Crt; type PVrchol = ^TVrchol; TVrchol = record x: integer; L,P: PVrchol end; procedure Pridej( var strom: PVrchol; hodnota: integer ); begin if strom = NIL then begin new( strom ); strom^.x := hodnota; strom^.L := NIL; strom^.P := NIL end else if hodnota < strom^.x then Pridej( strom^.L, hodnota ) else if hodnota > strom^.x then Pridej( strom^.P, hodnota ) else RunError( 777 ) end; procedure Vymaz( var prvek: PVrchol ); var vyhodit, p, minp: PVrchol; begin { if (prvek^.L = NIL) and (prvek^.P = NIL) then begin dispose( prvek ); prvek := NIL end else if (prvek^.L = NIL ) then begin vyhodit := prvek; prvek := prvek^.P; dispose( vyhodit ) end {} if (prvek^.L = NIL) then begin vyhodit := prvek; prvek := prvek^.P; dispose( vyhodit ) end else if (prvek^.P = NIL) then begin vyhodit := prvek; prvek := prvek^.L; dispose( vyhodit ) end else { ma DVA potomky: } begin p := prvek^.L; minp := NIL; while p^.P <> NIL do begin minp := p; p := p^.P end; prvek^.x := p^.x; if minp <> NIL then minp^.P := p^.L else prvek^.L := p^.L; dispose( p ); end end; procedure VytiskniStrom( var kamX: integer; kamY: integer; strom: PVrchol ); begin if strom <> NIL then begin VytiskniStrom( kamX, kamY+3, strom^.L ); gotoXY( 5*kamX, kamY ); write( strom^.x,' ' ); Inc( kamX ); VytiskniStrom( kamX, kamY+3, strom^.P ) end; end; var strom: PVrchol; x: integer; begin ClrScr; strom := NIL; Pridej( strom, 10 ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Pridej( strom, 15 ); ClrScr;VytiskniStrom( x, 1, strom ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Pridej( strom, 12 ); ClrScr;VytiskniStrom( x, 1, strom ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Pridej( strom, 1 ); ClrScr;VytiskniStrom( x, 1, strom ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Pridej( strom, 7 ); ClrScr;VytiskniStrom( x, 1, strom ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Pridej( strom, 2 ); ClrScr;VytiskniStrom( x, 1, strom ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Pridej( strom, 3 ); ClrScr;VytiskniStrom( x, 1, strom ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Pridej( strom, 100 ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); writeln; readln; readln; Vymaz( strom^.P^.P ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Vymaz( strom^.L ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; Vymaz( strom ); ClrScr;x := 1;VytiskniStrom( x, 1, strom ); readln; readln; readln; readln; readln; readln; end.