To Find out max and min in 2d array of random numbers
I want to know how to find mean, max, min of randomly generated numbers in 2d array.
I just coded to produce random 2d array of numbers...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
int main()
{
int temp[3][7];
srand(time(0));
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 7; j++)
{
temp[i][j] = 20+ rand() % 31;
cout << temp[i][j] << endl;
}
}
system ("pause");
return 0;
}
|
First look up what max, min and mean is and have a go at writing a few lines of code. Then show us what you have if you have any problems.
http://www.mathsisfun.com/mean.html
Topic archived. No new replies allowed.