Ask questions about two algorithms. 1. it is known that the width of the rectangle O is $ ow and the height is $ oh. when the O ratio remains unchanged, the O is scaled to a width not greater than $ dw, and the height not greater than $ dh, for the rectangle D with the largest area, calculate the width of the rectangle D $ nw and the height $ nh2.a. implement the function functionprint ($ m, $ n); $ m is the row, $ n is the column, and returns a two-dimensional array. ask questions about the two algorithms for the format.
1. it is known that the width of the rectangle O is $ ow and the height is $ oh. when the O ratio remains unchanged, the O is scaled to a width not greater than $ dw, and the height not greater than $ dh, for the rectangle D with the largest area, evaluate the width of the rectangle D $ nw and high $ nh
2. a. implement function print ($ m, $ n); $ m is a row, $ n is a column, and a two-dimensional array is returned. the format is similar
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
B. implement function convert ($ array). $ array is a two-dimensional array and returns a two-dimensional array. for example, the relationship between $ array and its corresponding
16 17 18 19 20
15 14 13 12 11
6 7 8 9 10
5 4 3 2 1
Thank you!
------ Solution --------------------
Is this assignment assigned by the school teacher?
Think about it. it's not too difficult to clarify your ideas.
1: just take an equal ratio formula and make a decision.
2: The Law of even and odd rows
3: just like the above, you can find the maximum number.
------ Solution --------------------
PHP code
$a){ $arr[$k]=array_reverse($a); } return $arr;}print_r(convert($array));