Помогите решить пожалуйста, очень срочно!!! Нужно сделать до вечера в программе C++ Builder 6
![](https://st.uroker.com/files/e9a/e9ac16988742abc25430778947bb1793.png)
![](https://st.uroker.com/files/95e/95ed0c1bcc075c002415b4d0ff416415.png)
Ответы
#include <vcl.h>
#include <iostream>
#include <cstdlib>
#include <ctime>
#pragma hdrstop
#pragma argsused
#include <tchar.h>
#include <math.h>
#pragma package(smart_init)
#pragma resource "*.dfm"
TStringGrid *Grid;
int _tmain(int argc, _TCHAR* argv[])
{
// Create a StringGrid component
Grid = new TStringGrid(NULL);
Grid->Parent = this;
Grid->DefaultRowHeight = 20;
Grid->ColCount = 2;
Grid->FixedCols = 1;
Grid->Cells[0][0] = "Index";
Grid->Cells[1][0] = "Value";
// Input data into the StringGrid
int size = 10;
int *array = new int[size];
srand(time(NULL));
for (int i = 0; i < size; i++)
{
array[i] = rand() % 100;
Grid->Cells[0][i + 1] = i;
Grid->Cells[1][i + 1] = array[i];
}
// Perform calculation on the array
int sum = 0;
for (int i = 0; i < size; i++)
{
sum += array[i];
}
// Output the result in the StringGrid
Grid->RowCount = size + 2;
Grid->Cells[0][size + 1] = "Sum";
Grid->Cells[1][size + 1] = sum;
return 0;
}