#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n=4, m=5;
int a[n][m];
srand(time(0));
int s=0;
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
a[i][j]=-99+rand()%199;
cout << setw(4) <<a[i][j];
s+=a[i][j];
}
cout << endl;
float r=float(s)/(m*n);
int k=0;
if(a[i][j]>r)
k++;
cout << "k = " << k;
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n=4, m=5;
int a[n][m];
srand(time(0));
int s=0;
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
a[i][j]=-99+rand()%199;
cout << setw(4) <<a[i][j];
s+=a[i][j];
}
cout << endl;
}
float r=float(s)/(m*n);
int k=0;
for(int i=0; i<n; i++)
for(int j=0; j<m; j++)
if(a[i][j]>r)
k++;
cout << "k = " << k;
return 0;
}