uva 10684 The jackpot

一道大水题。。。。。。。。
#include <cstdio>
#include <cstdlib>
#include <iostream>

using namespace std;
int num[10010],sumup[10010];
int main()
{
	int n,i,ans;
	while(~scanf("%d",&n)&&n)
	{
		//ans = 0;
		for(i=1; i <= n; ++i)
		{
			scanf("%d",&num[i]);
			sumup[i] = 0;
		}
		sumup[0] = 0;
		for(i=1;i <=n;++i)
		{
			if(sumup[i-1] > 0)
				sumup[i] = sumup[i-1] +num[i];
			else
				sumup[i] = num[i];
		}
		ans = sumup[1];
		for(i=2;i<=n;++i)
		{
			if(sumup[i] >ans)
				ans = sumup[i];
		}
		if(ans > 0)
		printf("The maximum winning streak is %d.\n",ans);
		else
			printf("Losing streak.\n");
	}
	return 0;
}

你可能感兴趣的:(uva 10684 The jackpot)