1 5 1 2 -1 3 -2
5
#include "stdio.h"
int main()
{
int n,x,max;
int i,a,temp;
scanf("%d",&n); //n组测试数据
while(0<n){
scanf("%d",&x); //每组数组中有x个整数
scanf("%d",&temp);
max=temp;
for(i=1;i<x;i++){
scanf("%d",&a);
if(temp>0){temp+=a;}
else{temp=a; }
max=max>temp?max:temp;
}
printf("%d\n",max);
n--;
}
return 0;
}
原文:http://blog.csdn.net/user_longling/article/details/22042099