• Предмет: Информатика
  • Автор: dmytrozhaurov
  • Вопрос задан 4 месяца назад

Помогите решить пожалуйста, очень срочно!!! Нужно сделать до вечера в программе C++ Builder 6

Приложения:

Ответы

Ответ дал: MATHEMATICS123
1

#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;

}


dmytrozhaurov: А как это в C++ Builer 6 будет выглядеть?
Вас заинтересует