1. Си туралы түсінік


StringGrid компонентін баптау



бет43/54
Дата06.01.2022
өлшемі2,99 Mb.
#14337
1   ...   39   40   41   42   43   44   45   46   ...   54
StringGrid компонентін баптау:

Stringgrid1 компоненттері үшін ColCount және RowCount мәндерін орнатыңыз, мысалы, 3 – үш баған және үш жол, ал FixedCols және FixedRows-1.

Өйткені stringgrid2 және StringGrid3 компоненттері тек бір баған бар, олар ColCount = 1, RowCount = 3, ал FixedCols = 0 және FixedRows = 1. Options қасиетінде StringGrid1 компоненті үшін goEditing жолы және StringGrid2 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; ib = new double[n];

for(i=0; i
for(j=0; jCells[j+1][i+1]);
b[i]=StrToFloat(StringGrid2->Cells[0][i+1]);
}
for(i=0; ifor(s=0, j=0; jStringGrid3->Cells[0][i+1] = FloatToStrF(s, ffFixed,8,2);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
for(int i=0; idelete []a; delete []b;
ShowMessage("Память освобождена!");
Close();
}


Достарыңызбен бөлісу:
1   ...   39   40   41   42   43   44   45   46   ...   54




©emirsaba.org 2024
әкімшілігінің қараңыз

    Басты бет