有关DELPHI的程序问题...高分

来源:百度知道 编辑:UC知道 时间:2024/07/04 09:28:53
procedure tcommword.setbufferrouter(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12:integer);
var row,col,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12:integer;
begin
for row:=0 to 7 do
for col:=0 to 11 do
begin
if mygrid.selected[row,col] then
selected[row,col]:=1 ;
else selected[row,col]:=0 ;
end;
if col:=0 then
A1:=selected[0,0]+selected[1,0]*2+selected[2,0]*2*2+selected[3,0]*2*2*2+selected[4,0]*2*2*2*2+selected[5,0]*2*2*2*2*2+selected[6,0]*2*2*2*2*2*2+selected[7,0]*2*2*2*2*2*2*2
if col:=1 then
A2:=selected[0,1]+selected[1,1]*2+selected[2,1]*2*2+selected[3,1]*2*2*2+selected[4,1]*2*2*2*2+selected[5,1]*2*2*2*2*2+selected[6,1]*2*2*2*2*2*2+selected[7,1]*2*2*2*2*2*2*2
if col:=2 then
A3:=selected[0,2]+selected[1,2]*2+selected[2,2]*2*2+selected[3,2]*2*2*2+selected[4,2]*2*2*2*2+selected[5,2]*2*2*2*2*2+selected[6,2]*2*2*2*2*2*2+selected

刚好有空,来赚你的分了:)

没写成你那种函数的形式,感觉那样写有点思维错乱

在窗体上放一个StringGrid1,rowCount 设置成 9 (最后一行显示结果值),ColCount 设置成 12
FixedCols和FixedRows设置 0

代码如下

unit Unit1;

interface

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

type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
public
function BSysToInt(Value: String): Extended;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.BSysToInt(Value: String): Extended;
var
N, I, J: Integer;
t: String;
begin
N := Length(Value);
Result := 0;
for I := 1 to N do