
Veechschi
4 год назад
Напишите программу на С++Найдите среднее арифметическое элементов массива
ОТВЕТЫ

Joel Timo-Jaakko
Nov 26, 2020
#include <iostream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
using namespace std;
int main(){
setlocale(LC_ALL,"russian");
srand(time(NULL));
int sum=0;
int sredne;
const int N = 10;
int i;
int array[N];
for( i=0;i<N;i++ )
{
array[i]=rand() % 50;
cout << setw(5) << array[i];
}
cout<<endl;
for( i=0;i<N;i++ )
{
sum+=array[i];
sredne=sum;
sredne=sum/N;
}
cout << " Среднее арифметическое: "<< sredne<< endl;
}
549
Смежные вопросы: