Advertisement
warki10

trololo

Dec 15th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.90 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Image1: TImage;
  12.     Button1: TButton;
  13.     Button2: TButton;
  14.     Button3: TButton;
  15.     Button4: TButton;
  16.     procedure FormCreate(Sender: TObject);
  17.     procedure Button1Click(Sender: TObject);
  18.     procedure Button2Click(Sender: TObject);
  19.     procedure Button3Click(Sender: TObject);
  20.     procedure Button4Click(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   Form1: TForm1;
  29.           j,m,n,g,f,b,bb,x,h,i:integer;
  30.           p:real;
  31.           c:Tcanvas;
  32.           a:array [1..20] of integer;
  33.           d:array [1..10] of integer;
  34. implementation
  35.  
  36. {$R *.dfm}
  37.  
  38. procedure TForm1.FormCreate(Sender: TObject);
  39. begin
  40.     c:=Image1.Canvas;
  41.     c.Brush.Color:=clwhite;
  42.     c.Pen.Color:=clblack;
  43.     c.Rectangle(0,0,image1.Width,image1.Height);
  44.        f:=20;
  45.        x:=20;
  46. end;
  47.  
  48. procedure TForm1.Button1Click(Sender: TObject);
  49. begin
  50.         h:=20+20;
  51.         x:=20;
  52.         randomize;
  53.         for i:=1 to length(a)do begin
  54.         j:=random(10);
  55.  
  56.  
  57.                 if j>6 then    begin
  58.                   c.Font.Color:=clred;
  59.                 end;
  60.                 if j<6 then begin
  61.                   c.Font.Color:=clblack;
  62.                 end;
  63.                 c.TextOut(x,h,inttostr(j));
  64.         x:=x+8;
  65.         end;
  66.  
  67. end;
  68.  
  69. procedure TForm1.Button2Click(Sender: TObject);
  70. begin
  71.  
  72.                 c.Brush.Color:=clwhite;
  73.                 c.Pen.Color:=clblack;
  74.                 c.Rectangle(0,0,image1.Width,image1.Height);
  75.         n:=0;
  76.         m:=0;
  77.         g:=0;
  78.         x:=20;
  79.        for i:=1 to 10 do begin
  80.         g:=random(20);
  81.         n:=n+g;
  82.  
  83.         c.TextOut(x,20+f,inttostr(g));
  84.         x:=x+11;
  85.        end;
  86.         p:=n/i;
  87.        c.TextOut(20,20+2*f,'priemer '+floattostr(p));
  88.        c.TextOut(20,100,inttostr(n));
  89.  
  90.  
  91. end;
  92.  
  93. procedure TForm1.Button3Click(Sender: TObject);
  94. begin
  95.         g:=0;
  96.         randomize;
  97.       for i:=1 to length(d)do begin
  98.       d[i]:=random(10);
  99.  
  100.       c.TextOut(x,20+3*f,inttostr(d[i]));
  101.       x:=x+10;
  102.  
  103.       end;
  104.        bb:= d[1];
  105.        d[1]:=d[2];
  106.        d[2]:=bb;
  107.         for i:=1 to length(d)do begin
  108.                 c.TextOut(x,50,inttostr(d[i]));
  109.                 x:=x+10;
  110.         end;
  111.  
  112. end;
  113.  
  114. procedure TForm1.Button4Click(Sender: TObject);
  115. begin
  116.         for i:=1 to length(a) do begin
  117.           j:=random(10);
  118.           c.Font.Color:=clblack;
  119.            c.TextOut(x,120,inttostr(j));
  120.                 if j=4 then begin
  121.                 b:=b+1;
  122.                 j:=5;
  123.                 c.Font.Color:=clred;
  124.                 end;
  125.                         c.TextOut(x,20+(6*f),inttostr(j));
  126.                         x:=x+10;
  127.         end;
  128.         c.TextOut(50,50,'je ich '+inttostr(b));
  129.  
  130. end;
  131.  
  132. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement