摘要: #include <cstdlib>#include <iostream>#include <algorithm>using namespace std;//如何求解数组中子数组连续元素的之和的最大值 //这种算法应该是最高效的。O(N)复杂度//见于《编程珠玑》P77页 /*分治的方法来求解,对于前i个元素,其最大和要么在前i-1元素中 存数在maxsofar;要么在第i个元素结束,存储在maxendinghere中例如例子中的,当扫描元素6的位置时,其maxendinghere是9,其maxsofar是9;当扫描到-3时,maxendinghere是6, 阅读全文
posted @ 2013-05-30 15:52 夜雨阑珊 阅读(958) 评论(0) 推荐(0) 编辑