Ответ:
#include
#include
using namespace std;
void fillArray(int* arr, int size)
{
for (int i = 0; i < size; i++)
{
arr[i] = -100 + rand() % 201;
}
}
void showArray(int* arr, int size)
{
for (int i = 0; i < size; i++)
{
cout << arr[i] << " ";</p>
}
}
void maxElment(int* arr, int size)
{
int max = 0, maxi = 0;
for (int i = 0; i < size; i++)
{
if (arr[i] > max)
{
max = arr[i];
maxi = i;
}
}
cout << "\n\nMax = " << max << " Index = " << maxi;</p>
}
void minElement(int* arr, int size)
{
int min = 1000, mini = 0;
for (int i = 0; i < size; i++)
{
if (arr[i] < min)
{
min = arr[i];
mini = i;
}
}
cout << "\n\nMin = " << min << " Index = " << mini;</p>
}
int Sum(int* arr, int size)
{
int sum = 0;
for (int i = 0; i < size; i++)
{
if (arr[i] > 0)
{
sum += arr[i];
}
}
return sum;
}
int nullArray(int* arr, int size)
{
int k = 0;
for (int i = 0; i < size; i++)
{
if (arr[i] == 0)
{
k++;
}
}
return k;
}
int main()
{
srand(time(0));
cout << "Input size array - ";</p>
int size = 0;
cin >> size;
int* arr = new int[size];
fillArray(arr, size);
showArray(arr, size);
maxElment(arr, size);
minElement(arr, size);
cout << "\n\nSum = " << Sum(arr, size);</p>
cout << "\n\nNullArr = " << nullArray(arr, size);</p>
delete[]arr;
return 0;
}
Объяснение: