NoNameCracksInc

Delphi

Jan 15th, 2014
7,224
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.27 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.     Image2: TImage;
  14.     Button2: TButton;
  15.     procedure Button1Click(Sender: TObject);
  16.     procedure Button2Click(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.   a:array[1..10]of integer;
  26.   d:integer;
  27.   q:real;
  28.   c:integer;
  29.  
  30. implementation
  31.  
  32. {$R *.dfm}
  33.  
  34. procedure TForm1.Button1Click(Sender: TObject);
  35. begin
  36.  randomize;
  37.  Image1.Canvas.Rectangle(0,0,Image1.Width,Image1.Height);
  38.  
  39.  for c:=1 to 10 do begin
  40.  a[c]:=random(100);
  41.  Image1.Canvas.TextOut(0+c*20,10,inttostr(a[c]));
  42.  d:=d+a[c];
  43. end;
  44.  
  45.  q:=d/10;
  46.  Image2.Canvas.TextOut(20,10,floattostr(q));
  47.  d:=0;
  48.  
  49. end;
  50. procedure TForm1.Button2Click(Sender: TObject);
  51.  var p,l,n,q:integer;
  52.  var x,y:integer;
  53.  
  54. begin
  55.  l:=0;
  56.  n:=100;
  57.  
  58.  for p:=1 to 10 do begin
  59.  if l<a[p] then begin
  60.  l:=a[p];
  61.  x:=p;
  62.  end;
  63.  
  64.  for q:=1 to 10 do begin
  65.  if n>a[q] then begin
  66.  n:=a[q];
  67.  y:=q;
  68.  
  69.  end;
  70.  end;
  71.  end;
  72.       Image1.Canvas.TextOut(0+x*20,10,inttostr(n));
  73.       Image1.Canvas.TextOut(0+y*20,10,inttostr(l));
  74. end;
  75. end.
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment