Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls;
- type
- TForm1 = class(TForm)
- Image1: TImage;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- j,m,n,g,f,b,bb,x,h,i:integer;
- p:real;
- c:Tcanvas;
- a:array [1..20] of integer;
- d:array [1..10] of integer;
- implementation
- {$R *.dfm}
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- c:=Image1.Canvas;
- c.Brush.Color:=clwhite;
- c.Pen.Color:=clblack;
- c.Rectangle(0,0,image1.Width,image1.Height);
- f:=20;
- x:=20;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- h:=20+20;
- x:=20;
- randomize;
- for i:=1 to length(a)do begin
- j:=random(10);
- if j>6 then begin
- c.Font.Color:=clred;
- end;
- if j<6 then begin
- c.Font.Color:=clblack;
- end;
- c.TextOut(x,h,inttostr(j));
- x:=x+8;
- end;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- c.Brush.Color:=clwhite;
- c.Pen.Color:=clblack;
- c.Rectangle(0,0,image1.Width,image1.Height);
- n:=0;
- m:=0;
- g:=0;
- x:=20;
- for i:=1 to 10 do begin
- g:=random(20);
- n:=n+g;
- c.TextOut(x,20+f,inttostr(g));
- x:=x+11;
- end;
- p:=n/i;
- c.TextOut(20,20+2*f,'priemer '+floattostr(p));
- c.TextOut(20,100,inttostr(n));
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- g:=0;
- randomize;
- for i:=1 to length(d)do begin
- d[i]:=random(10);
- c.TextOut(x,20+3*f,inttostr(d[i]));
- x:=x+10;
- end;
- bb:= d[1];
- d[1]:=d[2];
- d[2]:=bb;
- for i:=1 to length(d)do begin
- c.TextOut(x,50,inttostr(d[i]));
- x:=x+10;
- end;
- end;
- procedure TForm1.Button4Click(Sender: TObject);
- begin
- for i:=1 to length(a) do begin
- j:=random(10);
- c.Font.Color:=clblack;
- c.TextOut(x,120,inttostr(j));
- if j=4 then begin
- b:=b+1;
- j:=5;
- c.Font.Color:=clred;
- end;
- c.TextOut(x,20+(6*f),inttostr(j));
- x:=x+10;
- end;
- c.TextOut(50,50,'je ich '+inttostr(b));
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement