.


:




:

































 

 

 

 


TstringGrid




TStringGrid Additional . . , . ColCount RowCount 2, FixedCols FixedRows 1. StringGrid2 StringGrid3 , : ColCount=1, RowCount=2, FixedCols=0 FixedRows=1. TStringGrid , Options goEditing StringGrid1 StringGrid2 True.

.

 

Unit Rab_4;

Interface

Uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, ExtCtrls, Grids;

 

type

TInputForm = class(TForm)

StringGrid1: TStringGrid;

StringGrid2: TStringGrid;

StringGrid3: TStringGrid;

Label1: TLabel;

Edit1: TEdit;

Button1: TButton;

Button2: TButton;

Procedure FormCreate(Sender: TObject);

Procedure Button1Click(Sender: TObject);

Procedure Button2Click(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

 

const

Nmax = 10; //

type

Mas1 = array[1..Nmax] of Extended; //

Mas2 = array[1..Nmax, 1..Nmax] of Extended; //

var

InputForm: TInputForm;

A: Mas2; //

B, Y: Mas1; //

N, i, j: integer;

 

Implementation

 

{$R *.DFM}

 

Procedure TInputForm.FormCreate(Sender: TObject);

begin

N:= 3; //

Edit1.Text:= FloatToStr(N);

//

StringGrid1.ColCount:= N + 1;

StringGrid1.RowCount:= N + 1;

StringGrid2.RowCount:= N + 1;

StringGrid3.RowCount:= N + 1;

//

StringGrid1.Cells[0, 0]:= ' A';

StringGrid2.Cells[0, 0]:= ' B';

StringGrid3.Cells[0, 0]:= ' Y';

//

for i:=1 to N do

begin

StringGrid1.Cells[0, i]:= 'i='+ IntToStr(i);

StringGrid1.Cells[i, 0]:= 'j='+ IntToStr(i);

end;

end;

 

Procedure TInputForm.Button1Click(Sender: TObject);

begin

N:= StrToInt(Edit1.Text);

//

StringGrid1.ColCount:= N + 1;

StringGrid1.RowCount:= N + 1;

StringGrid2.RowCount:= N + 1;

StringGrid3.RowCount:= N + 1;

//

for i:=1 to N do

begin

StringGrid1.Cells[0, i]:= 'i=' + IntToStr(i);

StringGrid1.Cells[i, 0]:= 'j=' + IntToStr(i);

end;

end;

 

Procedure TInputForm.Button2Click(Sender: TObject);

var

s: extended;

begin

// A StringGrid1

for i:=1 to N do

for j:=1 to N do

A[i, j]:= StrToFloat(StringGrid1.Cells[j, i]);

// B StringGrid2

for i:=1 to N do

B[i]:= StrToFloat(StringGrid2.Cells[0, i]);

// A B

for i:=1 to N do

begin

s:= 0;

for j:=1 to N do

s:= s + A[i, j]*B[j];

Y[i]:= s;

// StringGrid3

StringGrid3.Cells[0, i]:= FloatToStrF(Y[i], ffFixed,6,2);

end;

end;

 

end.

 

 

Tedit TLabel. TLabel. TStringGrid, 0- 0- . , TButton.

1. . B, k- 0, k- , 1 .

2. . B, k- 1, k- , 0 .

3. . B, k- 1, k - , 0 .

4. . k - "" , "", .

5. . k - "" , , , .

6. . k - (. . ).

7. . .

8. . .

9. . .

10. , n- .

11. . , , .

12. n- , , .

13. n-o , , , .

14. , , .

15. - -1 , .

16. k . , , , .

17. , 1 k , . .

18. . , .

19. .

20. .

21. k .

22. n .

23. : , , , , .

24. X Y . Z , .

25. k . , . . .

26. . , .

27. (.. , : ).

28. . , .

29. k , .

30. , k ( ).


5.





:


: 2016-07-29; !; : 553 |


:

:

, .
==> ...

1507 - | 1414 -


© 2015-2024 lektsii.org - -

: 0.017 .