高分求demo(有界面)(200分)

  • 主题发起人 主题发起人 hssci0488
  • 开始时间 开始时间
H

hssci0488

Unregistered / Unconfirmed
GUEST, unregistred user!
高分求demo(有界面)主要是6列数据1+3列和2+4列比较后大则放5列小则放6列分
不够再加,小弟刚学,有程序没界面的提示不会用,运行后这差什么就是哪没声明
 
unit Unit3;
interface

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

type
TForm1 = class(TForm)
Button1: TButton;
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
procedure Ini;
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
Randomize;
end;

procedure TForm1.Ini;
var
i,j:byte;
begin
with stringgrid1 do begin
for i:=0 to 4 do
for j:=0 to 4 do begin
if i=0 then
cells[0,j]:=IntTostr(j)
else if j=0 then
cells[i,0]:=IntTostr(i)
else
cells[i,j]:=IntToStr(Random(100)+1);
end;
cells[5,0]:=IntTostr(5);
cells[6,0]:=IntTostr(6);
for i:=5 to 6 do
for j:=1 to 4 do
cells[ i,j]:='';
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i:byte;
Rect:TRect;
begin
Ini;
with stringgrid1 do
for i:=1 to Rowcount-1 do
if (strToInt(cells[1, i])+strToInt(cells[3, i]))>(strToInt(cells[2, i])+strToInt(cells[4, i])) then
cells[5,i]:= IntToStr((strToInt(cells[1, i])+strToInt(cells[3, i]))-(strToInt(cells[2, i])+strToInt(cells[4, i])))
else
cells[6,i]:= IntToStr((strToInt(cells[2, i])+strToInt(cells[4, i]))-(strToInt(cells[1, i])+strToInt(cells[3, i])));
StringGrid1DrawCell(Sender, 1, 1,rect,gdFixed);
end;


end.
 
后退
顶部