Pay attention to line: 33. Script is supposed to print out smallest number in two dimensional array. It doesnt work - how can i fix it?
Code:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main ()
{
int i, j, min = 0, ri = 0, ki = 0, m[4][4];
double s = 0;
bool highest;
srand ( time(NULL) );
for (i=0; i<4; i++){
for (j=0; j<4; j++)
m[i][j] = (rand() % 50 + 1);
}
cout <<"Elements:" <<endl;
for (i=0; i<4; i++){
for (j=0; j<4; j++)
cout<< m[i][j] <<" ";
cout <<endl;
}
if (highest == true){
min = 51;
}
for (i=0; i<4; i++){
for (j=0; j<4; j++)
if((min < m[i][j]) == highest){
min = m[i][j];
ri = i;
ki = j;
}
}
cout << "Smallest number " <<min <<" and its on " <<ri <<" row and " <<ki <<" column" <<endl;
for (j=0; j<4; j++)
s = (s + m[0][j]);
cout << "0. row avarage number " << s/4 <<endl;
system ("pause");
return 0;
}