Program darazs; uses crt,graph; const path = {'c:\turbo7\bgi'; }{Bgi utvonala} 'c:\tp\70\bgi'; max=1000; Type tomb=array [1..2] of byte; var szi:integer; hol,elemszam:integer; s,seged,kilepo:char; n,a:integer; d,t:tomb; Procedure Szovegesre; begin CloseGraph; {lezarja a grafikus uzemmodot} RestoreCrtMode; {Visszaallitja az InitGraph meghivasa elotti kepernyokezelesi modot} end; Procedure Grafikusra; Var gd,gm : integer; Begin DetectGraph(gd,gm); {detektalja a grafikus eszkozt} InitGraph(gd,gm,path); {inicializalja a grafikus rendszert} End; Procedure szimido(x,y:integer); var sv:string; Begin setfillstyle(1,black); bar(x,y,x+100,y+15); szi:=szi+1; str(szi,sv); sv:='Szim id“:'+sv; setcolor(lightred); outtextxy(x,y,sv); Delay(60); End; procedure tengely(bfx,bfy,jax,jay:integer); var x,y:integer; begin line(bfx+10,bfy+10,bfx+10,bfy+140); {y tengely} outtextxy(bfx+2,bfy+18,'Y'); line(bfx+10,bfy+140,jax-10,jay-10); {x tengely} outtextxy(jax-25,jax-8,'X'); line(bfx+10,bfy+10,bfx+15,bfy+15); line(bfx+10,bfy+10,bfx+5,bfy+15); line(jax-15,jay-15,jax-10,jay-10); line(jax-15,jay-5,jax-10,jay-10); end; Procedure szimnev(x,y:integer; nev:string); Begin setfillstyle(solidfill,blue); bar(x-5,y-5,x+550,y+10); setcolor(yellow); outtextxy(x,y,nev); End; Procedure szimlepes; var i:integer; Begin Randomize; i:=random(n); If d[i]=1 then Begin d[i]:=2; a:=a-1; t[a]:=t[a]+1; End Else Begin d[i]:=1; a:=a+1; t[a]:=t[a]+1; End; End; Procedure szimter(bfx,bfy,jax,jay:integer); var fx,x,y,i:integer; Begin randomize; rectangle(bfx,bfy,jax,jay); fx:=round((bfx+jax)/2); line(fx,bfy,fx,jay); For i:=1 to a do Begin x:=random(fx-bfx-1)+bfx+1; y:=random(jay-bfy-1)+bfy+1; putpixel(x,y,white); End; For i:=a+1 to n do Begin x:=random(jax-fx-1)+fx+1; y:=random(jay-bfy-1)+bfy+1; putpixel(x,y,white); End; setcolor(yellow); End; Procedure grafikon(bfx,bfy,jax,jay:integer); Begin rectangle(bfx,bfy,jax,jay); End; Procedure parameterno; var p:pointer; sv:char; Begin GetImage(100,230,450,370,P^); Repeat setfillstyle(solidfill,blue); bar(100,230,450,370); setcolor(yellow); outtextxy(225,235,'Param‚ter'); sv:=readkey; Until sv=#27; PutImage(100,230,P^,normalput); End; Procedure parameter(bfx,bfy,jax,jay:integer); var sv:char; p:pointer; n1:string; Begin setcolor(yellow); rectangle(bfx,bfy,jax,jay); str(n,n1); n1:='A darazsak sz ma:'+n1; outtextxy(bfx-226,bfy+3,n1); str(a,n1); n1:='Az 1.-ben a m. akt. sz ma:'+n1; outtextxy(bfx-226,bfy+13,n1); End; Procedure normal; Begin setcolor(yellow); outtextxy(55,450,'Norm l'); setcolor(lightred); outtextxy(55,450,'N'); End; Procedure csendes; Begin setcolor(yellow); outtextxy(120,450,'Csendes'); setcolor(lightred); outtextxy(120,450,'C'); End; Procedure grafikonbeki; Begin setcolor(yellow); outtextxy(190,450,'Grafikon be/ki'); setcolor(lightred); outtextxy(190,450,'G'); End; Procedure Lepesenkent; Begin setcolor(yellow); outtextxy(315,450,'L‚p‚senk‚nt'); setcolor(lightred); outtextxy(315,450,'L'); End; Procedure parameterek; Begin setcolor(yellow); outtextxy(415,450,'Param‚ter'); setcolor(lightred); outtextxy(415,450,'P'); End; Procedure kilep; Begin setcolor(yellow); outtextxy(500,450,'Kil‚p'); setcolor(lightred); outtextxy(500,450,'K'); End; Procedure help; Begin setcolor(yellow); outtextxy(555,450,'Help'); setcolor(lightred); outtextxy(555,450,'H'); End; Procedure help1; var sv:char; p:pointer; Begin GetImage(100,230,450,370,P^); Repeat setfillstyle(solidfill,blue); bar(100,230,450,370); setcolor(yellow); outtextxy(225,235,'Seg¡ts‚g'); sv:=readkey; Until sv=#27; PutImage(100,230,P^,normalput); End; Procedure menuki(bfx,bfy,jax,jay:integer); forward; Procedure kilep1(var seged:char); Begin seged:=' '; Repeat setfillstyle(solidfill,blue); bar(50,430,600,470); setcolor(yellow); outtextxy(205,450,'Kil‚p‚s M‚gsem El”lr‹l'); setcolor(lightred); outtextxy(205,450,'K'); setcolor(lightred); outtextxy(285,450,'M'); setcolor(lightred); outtextxy(365,450,'E'); seged:=Readkey; Until (seged='k') or (seged='K') or (seged='m') or (seged='M') or (seged='E') or (seged='e'); If (seged='k') or (seged='K') Then kilepo:='v' Else menuki(50,430,600,470); End; Procedure menu(bfx,bfy,jax,jay:integer;var hol:integer); var c:char; Begin Repeat s:=readkey; If s=#0 then begin c:=readkey; case c of #75: begin case hol of 2: Begin setfillstyle(solidfill,green); bar(bfx,bfy+5,bfx+55,jay-5); normal; setfillstyle(solidfill,blue); bar(bfx+60,bfy+5,bfx+125,jay-5); csendes; hol:=1; s:='v'; End; 1: Begin setfillstyle(solidfill,blue); bar(bfx,bfy,bfx+55,jay); normal; setfillstyle(solidfill,green); bar(bfx+495,bfy+5,bfx+540,jay-5); help; hol:=7; s:='v'; End; 7: Begin setfillstyle(solidfill,blue); bar(bfx+495,bfy+5,bfx+540,jay-5); help; setfillstyle(solidfill,green); bar(bfx+443,bfy+5,bfx+490,jay-5); kilep; hol:=6; s:='v'; End; 6: Begin setfillstyle(solidfill,blue); bar(bfx+443,bfy+5,bfx+490,jay-5); kilep; setfillstyle(solidfill,green); bar(bfx+360,bfy+5,bfx+435,jay-5); parameterek; hol:=5; s:='v'; End; 5: Begin setfillstyle(solidfill,blue); bar(bfx+360,bfy+5,bfx+435,jay-5); parameterek; setfillstyle(solidfill,green); bar(bfx+260,bfy+5,bfx+350,jay-5); lepesenkent; hol:=4; s:='v'; End; 4: Begin setfillstyle(solidfill,blue); bar(bfx+260,bfy+5,bfx+350,jay-5); lepesenkent; setfillstyle(solidfill,green); bar(bfx+130,bfy+5,bfx+255,jay-5); grafikonbeki; hol:=3; s:='v'; End; 3: Begin setfillstyle(solidfill,blue); bar(bfx+130,bfy+5,bfx+255,jay-5); grafikonbeki; setfillstyle(solidfill,green); bar(bfx+60,bfy+5,bfx+125,jay-5); csendes; hol:=2; s:='v'; End; End; end; #77: begin case hol of 7: Begin setfillstyle(solidfill,green); bar(bfx,bfy+5,bfx+55,jay-5); normal; setfillstyle(solidfill,blue); bar(bfx+495,bfy+5,bfx+540,jay-5); help; hol:=1; s:='v'; End; 1: Begin setfillstyle(solidfill,blue); bar(bfx,bfy,bfx+55,jay); normal; setfillstyle(solidfill,green); bar(bfx+60,bfy+5,bfx+125,jay-5); csendes; hol:=2; s:='v'; End; 2: Begin setfillstyle(solidfill,blue); bar(bfx+60,bfy+5,bfx+125,jay-5); csendes; setfillstyle(solidfill,green); bar(bfx+130,bfy+5,bfx+255,jay-5); grafikonbeki; hol:=3; s:='v'; End; 3: Begin setfillstyle(solidfill,blue); bar(bfx+130,bfy+5,bfx+255,jay-5); grafikonbeki; setfillstyle(solidfill,green); bar(bfx+260,bfy+5,bfx+350,jay-5); lepesenkent; hol:=4; s:='v'; End; 4: Begin setfillstyle(solidfill,blue); bar(bfx+260,bfy+5,bfx+350,jay-5); lepesenkent; setfillstyle(solidfill,green); bar(bfx+360,bfy+5,bfx+435,jay-5); parameterek; hol:=5; s:='v'; End; 5: Begin setfillstyle(solidfill,blue); bar(bfx+360,bfy+5,bfx+435,jay-5); parameterek; setfillstyle(solidfill,green); bar(bfx+443,bfy+5,bfx+490,jay-5); kilep; hol:=6; s:='v'; End; 6: Begin setfillstyle(solidfill,blue); bar(bfx+443,bfy+5,bfx+490,jay-5); kilep; setfillstyle(solidfill,green); bar(bfx+495,bfy+5,bfx+540,jay-5); help; hol:=7; s:='v'; End; End; end; end; End; If s=#13 Then Begin case hol of 1: Begin s:='v'; End; 2: Begin s:='v'; End; 3: Begin s:='v'; End; 4: Begin s:='v'; End; 5: Begin parameterno; s:='v'; End; 6: Begin kilep1(seged); s:='v'; End; 7: Begin help1; s:='v'; End; End; End; until (s='v') or (s='V'); End; Procedure menuki(bfx,bfy,jax,jay:integer); Begin bar(bfx,bfy,jax,jay); setfillstyle(solidfill,green); bar(bfx+3,bfy+10,bfx+55,jay-10); normal; csendes; grafikonbeki; lepesenkent; parameterek; kilep; help; hol:=1; End; Begin Repeat WriteLn('K‚rem a darazsak maxim lis sz m t:'); ReadLn(n); Until (n<=max); Repeat WriteLn('K‚rem az 1.dobozba l‚v‹ darazsak sz m t:'); ReadLn(a); Until (a<=n); Grafikusra; szimnev(50,10,'Elemi dif£zi¢s g zmodell'); szimter(50,70,400,250); grafikon(50,250,400,400); tengely(50,250,400,400); parameter(630,70,400,400); menuki(50,430,600,470); repeat if keypressed then begin menu(53,435,655,465,hol); end; szimido(450,50); until (kilepo='V') or (kilepo='v'); Szovegesre; End.