30 10 swybr


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids;

type
TForm1 = class(TForm)
sg1: TStringGrid;
b_wypelnij: TButton;
b_sumuj: TButton;
e_suma: TEdit;

procedure b_wypelnijClick(Sender: TObject);
procedure b_sumujClick(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
tablica: array [0..29,0..9] of byte;
implementation

{$R *.DFM}




procedure TForm1.b_wypelnijClick(Sender: TObject);
var
x,y:integer;
begin
for x:=0 to 30 do
for y:=0 to 10 do
begin
tablica[x,y]:=random(101);
sg1.cells[x,y]:=inttostr(tablica[x,y]);
end;
end;

procedure TForm1.b_sumujClick(Sender: TObject);
var
x,y,suma:integer;
begin
suma:=0;
for x:=0 to 30 do
for y:=0 to 10 do if (tablica[x,y]mod 2)=0 then suma:=suma+tablica[x,y];
e_suma.text:=inttostr(suma);
end;

end.

Wyszukiwarka