- 博客(3)
- 资源 (1)
- 收藏
- 关注
原创 sicily 1137 河床
//大一大二以前看起来毫无思路的问题,现在积累思考多了,却很容易解决了#include#include#includeusing namespace std;int maxLen(int *a, int start, int end, int k){//special caseif( k==0 ){return 1;}if( k < 0 ){return 0;}if( start == end )
2013-09-18 16:58:09 738
原创 子数组最大和问题
#include #include #include using namespace std; /* maxSum[i] = max(maxSum[i-1], a[i], sum[j, i]) */ int maxSumOfSubarray(int a[], int n) { int maxSum , t; maxSum = t = a[0]; for( int i = 1; i < n
2013-09-15 16:29:34 465
原创 二分查找的几个用法
#include using namespace std; bool binary_search(int *a, int n, int x) { int left = 0, right = n-1; int mid; while( left <= right ) { int mid = left + (right - left) / 2; if( a[mid] == x )
2013-09-14 21:44:37 597
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人