#include <iostream>
#include <cstdlib>
#include <ctime>
typedef int datatype;
void init_array(datatype* arr, int SIZE)
{
for (int i = 0; i < SIZE; ++i)
arr[i] = rand() % 100;
}
void show_array(datatype* arr, int SIZE)
{
std::cout << "array: ";
for (int i = 0; i < SIZE; ++i)
std::cout << arr[i] << " ";
std::cout << "\n";
}
datatype find_sum(datatype* arr, int SIZE)
{
datatype sum = 0;
for (int i = 0; i < SIZE; ++i)
sum += arr[i];
return sum;
}
int main()
{
std::cout << "enter a size of the array: ";
int SIZE;
std::cin >> SIZE;
datatype *arr = new datatype[SIZE];
srand(time(NULL));
init_array(arr, SIZE);
show_array(arr, SIZE);
std::cout << "sum of elements: " << find_sum(arr, SIZE) << "\n";
delete[] arr;
return 0;
}
USES Graph;
VAR Device, Mode: Integer; 50 100 150 200 250 300
BEGIN Device:=0;
InitGraph(Device, Mode, ’<путь к графическим драйверам>’);
PutPixel(50,100,White); Rectangle(150,150,50,200); {правый верхний и левый нижний углы}
Circle(200,100,50); {окружность} {отрезок прямой}
Floodfill (200,100, red);
Line(100,50,250,150);
ReadLn;
CloseGraph;
END.