unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm1 = class(TForm)
tabl: TStringGrid;
Button1: TButton;
procedure FormActive(Sender:TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Unit2;
procedure TForm1.FormActive(Sender:TObject);
begin
tabl.Cells[0,3]:='Спартак';
tabl.Cells[0,2]:='Рубин';
tabl.Cells[0,1]:='Зенит;
tabl.Cells[0,4]:='Динамо';
tabl.Cells[1,0]:='Очки';
tabl.Cells[2,0]:='Игры';
tabl.Cells[3,0]:='Победы';
tabl.Cells[4,0]:='Ничьи';
tabl.Cells[5,0]:='Поражения';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.Show;
end;
end.
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm2 = class(TForm)
StringGrid1: TStringGrid;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
uses unit1;
procedure TForm2.Button2Click(Sender: TObject);
var
s,i,l,j: integer;
begin
for j:=1 to 2 do
begin
s:=0;
l:=0;
if StrToInt(StringGrid1.Cells[1,j])>StrToInt(StringGrid1.Cells[2,j])
then s:=s+3
else if StrToInt(StringGrid1.Cells[1,j])<StrToInt(StringGrid1.Cells[2,j])
then l:=l+3
else begin s:=s+1;
l:=l+1;
end;
for i:=1 to 4 do
begin
if Form1.tabl.Cells[0,i]=StringGrid1.Cells[0,j]
then Form1.tabl.Cells[1,i]:=IntToStr(s);
end;
for i:=1 to 4 do
begin
if Form1.tabl.Cells[0,i]=StringGrid1.Cells[3,j]
then Form1.tabl.Cells[1,i]:=IntToStr(l);
end;
end;
Form1.Show;
end;
end.