Answer the question
In order to leave comments, you need to log in
How to print the 5 largest elements of a matrix with their indices?
Display the 5 largest elements of the matrix with their indices, but I don’t know how to implement it, at least the idea
for (int i = 0; i < 5; ++i)
{
int temp_max_value = 0;
for (int j = 0; j < row; ++j)
{
for (int k = 0; k < column; ++k)
{
if(matrix[j][k] > temp_max_value)
{
temp_max_value = matrix[j][k];
}
}
}
printf("Max value %d\n", temp_max_value);
}
Answer the question
In order to leave comments, you need to log in
Idea: find the largest number of each line, drive them into a separate array, sort in ascending order and take the five extreme numbers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question