AntoSVK

Dvojpole

Feb 10th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.40 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, Grids;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     StringGrid1: TStringGrid;
  13.     Button2: TButton;
  14.     Label1: TLabel;
  15.     Button3: TButton;
  16.     Label2: TLabel;
  17.     Button4: TButton;
  18.     procedure Button4Click(Sender: TObject);
  19.     procedure Button3Click(Sender: TObject);
  20.     procedure Button2Click(Sender: TObject);
  21.     procedure FormCreate(Sender: TObject);
  22.     procedure Button1Click(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.   dvojpole:array[1..100,1..100] of integer;
  32.   i,j:integer;
  33.  
  34. implementation
  35.  
  36. {$R *.dfm}
  37.  
  38. procedure TForm1.Button1Click(Sender: TObject);
  39. begin
  40. randomize;
  41. label1.caption:='';
  42. label2.Caption:='';
  43. for i := 1 to 10 do
  44.   begin
  45.     for j := 1 to 10 do
  46.       begin
  47.         dvojpole[i,j]:=random(100)+1;     //NAPLNENIE POLA VO VNUTRI, KTORE EŠTE NEVIDNO
  48.  
  49.       StringGrid1.Cells[i,j]:=IntToStr(dvojpole[i,j]); //VONKAJSIE NAPLNENIE tStringGrid tabuľky
  50.       end;
  51.   end;
  52. end;
  53.  
  54.  
  55. procedure TForm1.Button2Click(Sender: TObject);
  56. var
  57. max,pozi,pozj:integer;
  58. begin
  59. //if dvojpole[0,0] then ;
  60.  
  61. max:=0;
  62. for i := 1 to 10 do
  63.   begin
  64.     for j := 1 to 10 do
  65.       begin
  66.         if max<dvojpole[i,j] then
  67.         begin
  68.          max:=dvojpole[i,j];
  69.          pozi:=i;
  70.          pozj:=j;
  71.         end;
  72.       end;
  73.   end;
  74. label1.Caption:=('Najväčšie číslo je: '+inttostr(max)+'. Na pozícii: '+'['+inttostr(pozi)+','+inttostr(pozj)+']');
  75. end;
  76.  
  77. procedure TForm1.Button3Click(Sender: TObject);
  78. begin
  79. label2.Caption:='Na pozícii [8,2] je číslo: '+(inttostr(dvojpole[8,2]));
  80.  
  81. end;
  82.  
  83. procedure TForm1.Button4Click(Sender: TObject);
  84. var
  85. pozx,pozy:integer;
  86. begin
  87. i:=1;
  88. for i := 1 to 10 do
  89.   begin
  90.     for j := 1 to 10 do
  91.       begin
  92.         pozx:=i*j;
  93.         pozy:=i*j;
  94.       //  inc(i);
  95.       end;
  96.   end;
  97. end;
  98.  
  99. procedure TForm1.FormCreate(Sender: TObject);
  100. begin
  101. for I := 1 to 10 do
  102.   begin
  103.     StringGrid1.Cells[0,i]:=IntToStr(i);
  104.     StringGrid1.Cells[i,0]:=IntToStr(i);
  105.   end;
  106.  
  107. end;
  108.  
  109. end.
Advertisement
Add Comment
Please, Sign In to add comment