unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TMyArray =
Array [1..2,1..4]
Of Integer;
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Edit3: TEdit;
StringGrid1: TStringGrid;
Edit1: TEdit;
Edit2: TEdit;
Edit4: TEdit;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Memo1: TMemo;
procedure Button7Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
MyArray: TMyarray;
implementation
{$R *.dfm}
procedure Fuellen;
var
Z, SP: Integer;
begin
Randomize;
for Z := 1
to 4
do
for SP := 1
to High(MyArray)
do
MyArray[SP, Z] := Random(101)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Fuellen;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
A1, A2:
String;
SP: Integer;
begin
Memo1.Visible := True;
A1 := '
';
for SP := 1
to 4
do
A1 := A1 + '
' + IntToStr(MyArray[1, SP]);
Memo1.Lines.Add(A1);
A2 := '
';
for SP := 1
to 4
do
A2 := A2 + '
' + IntToStr(MyArray[2, SP]);
Memo1.Lines.Add (A2);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
Row, Col: Integer;
begin
StringGrid1.Visible := True;
for Row := 0
to 2
do
for Col := 0
to 4
do
StringGrid1.Cells[Col, Row] := IntToStr(MyArray[ Row + 1, Col + 1])
end;
procedure TForm1.Button4Click(Sender: Tobject);
var
A1, A2 :
String;
SP : Integer;
begin
Edit3.Visible := True;
Edit1.Visible := True;
A1 := '
';
for SP := 1
to 4
do
A1 := A1 + '
' + IntToStr(MyArray[1, SP]);
Edit3.Text := A1;
A2 := '
';
for SP := 1
to 4
do
A2 := A2 + '
' + IntToStr(MyArray[2, SP]);
Edit1.Text := A2;
end;
procedure TForm1.Button6Click(Sender: TObject);
var
I,J, Summe, Anzahl: Integer;
Mitte: Real;
begin
Edit2.Visible := True;
Summe := 0;
for I := Low(Myarray)
to High(Myarray)
do
for J := Low(MyArray[i])
to High(MyArray[i])
do
begin
Summe := Summe + MyArray[I, J];
Inc(Anzahl);
end;
Mitte := Summe / Anzahl;
Edit2.Text := FloatToStr(Mitte);
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Button1.Caption := '
neu';
Button2.Caption := '
memo';
Button3.Caption := '
grid';
Button4.Caption := '
edit';
Button5.Caption := '
MWZeile';
Button6.Caption := '
MWKomplett';
Button7.Caption := '
close';
StringGrid1.ColCount := 4;
StringGrid1.RowCount := 2;
Memo1.Clear;
Edit1.Visible := False;
Edit2.Visible := False;
Edit3.Visible := False;
Edit4.Visible := False;
Stringgrid1.Visible := False;
Memo1.Visible := False;
end;
end.