hey guys!
so I need to create a matrix 6x6 and then fill it with random numbers from 0 to 3.... and I need to leave the diagonal of the matrix with 0s...
The rows are supposed to be soccer teams so if row 1 wins row 2... the program needs to print a 3... if it's a tie it's 1 and if row 1 loses it's 0... like that...
then I need to see which team makes more points and that is the one that wins....
so far I've created the matrix but I don't know how to print 0s in the diagonal or compare numbers that are in the matrix... please help!!!!
#include <cstdlib>
#include <ctime>
#include <iostream>
static const int conROWS = 6;
static const int conCOLS = conROWS;
int main(int argc, char* argv[])
{
double matrix[conROWS][conCOLS];
double maxvalue[conROWS];
double finalvalue;
int r,c;
srand(clock() + time( NULL )); //seed the random number generator
//fill matrix with random values in range 1..100
std::cout << "Matrix:" << std::endl;
for(r=0; r<conROWS; r++)
{
for(c=0; c<conCOLS; c++)
{
matrix[r][c] = (rand() % 4) ;
std::cout << matrix[r][c] << " ";
};
std::cout << std::endl;
};
//work out max row element
for(r=0; r<conROWS; r++)
{
maxvalue[r]= 0;
for(c=0; c<conCOLS; c++)
{
if(matrix[r][c] > maxvalue[r])
maxvalue[r] = matrix[r][c];
};
std::cout << " \nMax value in row " << r << " is " << maxvalue[r];
};
finalvalue = 0;
for(r=0; r<conROWS; r++)
{
if(maxvalue[r]>finalvalue)
finalvalue = maxvalue[r];
}
std::cout << " \nMax of row values is " << finalvalue << std::endl;
//todo workout max value overall and display it
system ("pause");
return 0;
};