2013年9月12日

分治法取最大值的实现

摘要: str = [2,3,1,5,8,4,0,7,9,2,3,1,5,8,4,0,7,9,2,3,1,5,8,4,0,7,9,2,3,1,5,8,4,0,7,9,2,3,1,5,8,4,0,7,9]def test1 arr len = arr.length (len%2==0)?(l = len/2):(l = (len+1)/2) ar = [] for i in 0..l-1 if arr[i*2+1]!=nil and arr[i*2]<arr[i*2+1] ar<<arr[i*2+1] else ar<<arr[i*2] end end... 阅读全文

posted @ 2013-09-12 11:46 张飞_ 阅读(306) 评论(0) 推荐(0) 编辑

导航