Question of two algorithms

Source: Internet
Author: User
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));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.