#include <ctime>
#include <iostream>
using namespace std;
int main()
{
int i;//Счётчик
srand(time(0));//усатнавливаем нач значение генератора случ числе
int N;//число элементов в массиве
int M;//число положительных элементов
int S;//Будет содержать сумму положит элементов
cout<<"Etern num of elements N : "/*;cin>>N;*/<<(N = 15)<<endl;
//Выделяем память под динамический массив
int * arr = new int[N];
//В цикле генерируем элементы, печатаем их,
//находим S и M короче всё в одном флаконе
cout<<"Array : "<<endl;
for(S = M = i = 0; i < N; i++)
{
//Случ число в пределах -50...50
cout<<(arr[i] = rand()%100 - 50)<<" ";
if(0 <=arr[i])
{
//решил расписать
S = S + arr[i];
M = M + 1;
}
}
cout<<endl;
if(M ==0)
cout<<"Array not contain positive elements"<<endl;
else
cout<<"Array contain "<<M<<" positive elements"<<endl
<<"Average value of positive elements : "<<(S * 1.0 / M)<<endl;
delete [] arr;//Чистим память
cout<<"Enter any key for exit...";
char chKey;cin>>chKey;
return 0;
}