Calling Min and Max from a 3D Array

I made a randomly generated 3D Array, but I need to call the Top three Max numbers and the Bottom three Minimum number.
How do I call the Mins/Maxs and cout three of each?


#include <iostream>
#include <cmath>

using namespace std;

int main() {
const int row = 3;
const int column = 3;
const int width = 3;

int fun[row][column][width];



for (int i = 0; i < row; i++) {
for (int j = 0; j < column; j++) {
for (int k = 0; k < width; k++) {
fun[row][column][width] = rand() % 10;
cout << " " << fun[row][column][width] << " ";
}
cout << endl;
}
cout << endl;

}


int mn, mx;

int a[3][3][3];

for (int i = 0; i < 28; i++)
{
fun[row][column][width] = a[3][3][3];
}

mn = a[0][0][0];
mx = a[0][0][0];
for (int i = 1; i < 28; i++)
{
cout << a[3][3][3] << endl;
if (mn > a[i][i][i])
{

mn = a[i][i][i];
cout << mn << endl;
}
else if (mx < a[i][i][i])
{
mx = a[i][i][i];
cout << mx << endl;
}
}

cout << "Maximum number is: " << mx << endl;
cout << "Minimum number is: " << mn << endl;
}
Topic archived. No new replies allowed.