There is a 3*4 matrix, and the program is required to find the value of the element with the largest value, as well as its row number and column number

Use the beating method. First find any number to stand on the stage, and compare the second number with it, and the winner (larger number) stays on the stage. Then go up to the third number, compare the size with the people on the stage (the winner just now), the winner will stay on the stage, and the loser will step down. From now on, each number will be compared with the number left on the stage at that time, until everyone has come to the stage to compare. The last one left on the stage is the champion. This is the "fighting arena algorithm".

The way of thinking about this question is as follows:

cea8de3f6d5c4b298074096b3836f0a4.jpg

 

9b65f90c67bf436295859bb152f86b87.png

 Notice:

Array name [constant expression], the constant expression can include constants and symbolic constants, but cannot contain variables. In other words, the C language does not allow dynamic definition of the size of the array, that is, the size of the array does not depend on the value of the variable during the running of the program.

Guess you like

Origin blog.csdn.net/m0_73939236/article/details/128089363