Answer the question
In order to leave comments, you need to log in
How to iterate over a matrix and compare its elements?
There is a code
#include <iostream>
using namespace std;
int comparare (int x , int y, int z) {
int Max ;
if(x > y && x > z) Max = x;
if(y > x && y > z) Max = y;
if(z > x && z > y) Max = z;
cout << "\n - " << "x = " << x << " y = " << y << " z = "<< z << endl;
}
int main()
{
const unsigned int DIM1 = 5;
const unsigned int DIM2 = 5;
int one, two, three, j , n = 4;
int ary[DIM1][DIM2] = {
{ 1, 0, 0, 0, 0,},
{ 2, 4, 0, 0, 0},
{ 3, 6, 9, 0, 0},
{ 2, 7, 6, 8, 0 },
{ 2, 7, 6, 8, 0 }
};
for (int test = 0 ; test < (n-1) ; test ++) {
for (int i = test ; i < (n-1) ; ) {
one = ary [i][i];
for ( j = i ; j < (i+1) ;j++ ) {
two = ary [j+1][i];
}
i++;
three= ary [i][j];
comp (one,two,tree);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question