请问两个算法的题目

WBOY
Release: 2016-06-13 13:37:20
Original
1048 people have browsed it

请教两个算法的题目
1.已知矩形O的宽$ow,高$oh,在保持O的比例不变的情况下将O缩放为宽不大于$dw,高不大于$dh,且面积最大的矩形D,求矩形D的宽$nw和高$nh

2.a.实现函数function print($m,$n);$m为行,$n为列,返回一个二维数组,格式类似于下图
1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16

b.实现函数function convert($array),$array为一个二维数组,返回一个二维数组,于$array的关系如上图和下图对应
16 17 18 19 20
15 14 13 12 11
6 7 8 9 10
5 4 3 2 1

请各位不吝赐教,谢谢!

------解决方案--------------------
这是学校老师布置的作业吧?
好好想一想,理清思路不会太难
1:就一个等比公式,判断下就好了

2:偶数,奇数行的规律

3:和上面的一样,求出最大数就行了。
------解决方案--------------------

PHP code
$a){ $arr[$k]=array_reverse($a); } return $arr; } print_r(convert($array)); 
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!