c saddle element in matrix

0 Danny AA · December 22, 2014
int CheckSaddleElement(int mat[][COLS], int rows)

{

int i=0, j=0, k=0;

int min = 0, max = 0, col = 0;

for (i = 0; i < rows; i++)

{

min = mat[0];

for (j = 0; j < 10; j++)

{

if (mat[j] <= min)

{

min = mat[j];

}

col = j;

}

max = mat[0]
;

for (k = 0; k < rows; k++)

{

if (mat[k]
>= max)

max = mat[k]
;

}

}

if (max == min)

return 1;

return 0;


I don't know why it doesn't work.....I need help pls

}

Post a Reply

Replies

Oldest  Newest  Rating
0 Danny AA · December 31, 2014
both of them are working great,
Thanks for your help....:D
0 Franz Schmidt · December 30, 2014
Ok now I understand what you mean :D
Look if it works: https://paste.ab-storm.de/view/167976081c965cea485999cbe13ce336
0 Danny AA · December 23, 2014
1 2 0 3 9 4 5 3 6 7
2 4 3 5 9 0 2 3 4 1
5 3 4 7 6 1 9 0 4 2 
6 9 7 8 6 7 7 4 5 6
8 3 1 9 2 0 6 2 8 2
2 7 3 0 3 6 3 1 5 3
8 2 5 9 7 7 8 3 7 3
1 7 4 8 5 8 5 0 0 6

that's tha matrix and the func need to return 1 cuz there is a saddle element.
which is number 4.
row 3 column 7.
int checkSaddleElement (int mat[][COLS], int ros);
i have tried your func and it doesn't work.
tnx for your help.
0 Franz Schmidt · December 22, 2014
You mean something like this?

http://textuploader.com/6s7b

Or sth. different?
0 Danny AA · December 22, 2014
i need to make a func that find the smallest number in rows and biggest number in columns in a given matrix.
0 Franz Schmidt · December 22, 2014
Could you please explain what we are supposed to help you with?
Sorry but we can't read your mind :angel:
-1 Danny AA · December 22, 2014
can someone help me with that pls?
  • 1

C

107,073 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator