.


:




:

































 

 

 

 


StringGrid




StringGrid 1 ColCount RowCount , , 3 , FixedCols FixedRows 1.

StringGrid 2 StringGrid 3 , ColCount = 1, RowCount = 3, FixedCols = 0 FixedRows = 1.

Options goEditing StringGrid 1 StringGrid 2 true.

n - EditChange, Edit.

:

...

//---------------------- -------------------

int n = 3;

double **a, *b; //

//---------------------------------------------------------------------------

void __fastcall TForm1:: FormCreate (TObject *Sender)

{

Edit1->Text=IntToStr(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(int i=1; i<=n;i++){

StringGrid1->Cells[0][i]="i="+IntToStr(i);

StringGrid1->Cells[i][0]="j="+IntToStr(i);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1:: Edit1Change (TObject *Sender)

{

int i;

n=StrToInt(Edit1->Text);

StringGrid1->ColCount = n+1; StringGrid1->RowCount = n+1;

StringGrid2->RowCount = n+1; StringGrid3->RowCount = n+1;

for(i=1; i<=n;i++){

StringGrid1->Cells[0][i]="i="+IntToStr(i);

StringGrid1->Cells[i][0]="j="+IntToStr(i);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1:: Button1Click (TObject *Sender)

{

double s;

int i,j;

a = new double*[n]; //

for(i=0; i<n;i++) a[i] = new double[n]; //

b = new double[n];

// StringGrid1 StringGrid2

for(i=0; i<n;i++) {

for(j=0; j<n;j++) a[i][j]=StrToFloat(StringGrid1->Cells[j+1][i+1]);

b[i]=StrToFloat(StringGrid2->Cells[0][i+1]);

}

// s StringGrid3

for(i=0; i<n;i++){

for(s=0, j=0; j<n;j++) s += a[i][j]*b[j];

StringGrid3->Cells[0][i+1] = FloatToStrF(s, ffFixed,8,2);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1:: Button2Click (TObject *Sender)

{

delete []a;

delete []b;

ShowMessage(" !");

Close();

}

:

...

void main()

{

double **a, *b, s;

int i, j, n;

printf(" Input size N: "); scanf("%d",&n);

a = new double*[n]; //

for(i=0; i<n;i++)

a[i] = new double[n]; //

b = new double[n];

puts("\n Input Massiv A:");

for(i=0; i<n;i++)

for(j=0; j<n;j++) scanf("%lf", &a[i][j]);

puts("\n Input Massiv B:");

for(i=0; i<n;i++) scanf("%lf", &b[i]);

puts("\n Massiv Y:");

for(i=0; i<n;i++){

for(s=0, j=0; j<n;j++) s+=a[i][j]*b[j];

printf(" %8.2lf ", s);

}

delete []a;

delete []b;

puts("\n Delete!");

puts("\n Press any key... ");

getch();

}

:


. . () Label, StringGrid, 0- 0- .

1. N ´ M B, k- 0, k - , 1.

2. N ´ M B, k- 1, k - , 0.

3. N ´ M B, k- 1, k - , 0.

4. N ´ M. , , .

5. N ´ M. , , .

6. N ´ M. , .. .

7. N ´ M .

8. N ´ M .

9. N ´ M .

10. , .

11. N ´ M. , , .

12. , .

13. , .

14. N ´ M , , .

15. n n- 1 , .

16. n , , , .






:


: 2018-10-15; !; : 235 |


:

:

, .
==> ...

1670 - | 1489 -


© 2015-2024 lektsii.org - -

: 0.016 .