01-复杂度2. Maximum Subsequence Sum (25)

#include
#include
using namespace std;
int main()
{
	int n;
	while((cin>>n)!=NULL)
	{
		vector number;
		int temp;
		for(int i=0;i>temp;
			number.push_back(temp);
		}
		int maxsum=-1,indexsum=0,left=number[0],right=number[n-1],curleft=number[0];
		for(int i=0;imaxsum)
			{
				maxsum=indexsum;
				right=number[i];
				left=curleft;
			}
			else if(indexsum<0)
			{
				indexsum=0;
				if(i!=n-1)
					curleft=number[i+1];
			}
		}
		if(-1==maxsum)
			maxsum=0;
		cout<

你可能感兴趣的:(Pat--陈越,何钦铭-数据结构基础习题集)