wtorek, 30 maja 2023

Dynamic array - Visual C++


 

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

int i, j;

 

array<System::Int64, 2>^ tabInt = gcnew array<System::Int64, 2>(10, 10);

array<System::Double, 2>^ tabDouble = gcnew array<System::Double, 2>(10, 10);

dataGridView1->ColumnCount = 10; dataGridView2->ColumnCount = 10;

dataGridView1->RowCount = 10; dataGridView2->RowCount = 10;

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

{

dataGridView1->Rows[i]->DefaultCellStyle->BackColor =

System::Drawing::Color::BlueViolet;

dataGridView2->Rows[i]->DefaultCellStyle->BackColor = System::Drawing::Color::Beige;

dataGridView1->Columns[i]->Width = 50;

dataGridView2->Columns[i]->Width = 50;

dataGridView1->Rows[i]->Height = 25;

dataGridView2->Rows[i]->Height = 25;

}

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

{

for (j = 0; j < 10; j++)

{

tabInt[i, j] = (i + 1) * (j + 1);

tabDouble[i, j] = sqrt(1.00 * tabInt[i, j]);

dataGridView1->Rows[i]->Cells[j]->Value = tabInt[i, j].ToString();

dataGridView2->Rows[i]->Cells[j]->Value = tabDouble[i, j].ToString();

}

}

}