View Code of Problem 19

#include<stdio.h>
int main(){
	int n,i;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		int res[n];
		for(i = 0;i < n; i++){
			scanf("%d",&res[i]);    //输入 
			}
		int max = res[0];
		int add = 0;
		for(i = 0;i < n; i++){
		add = add +res[i];
		if(add>max) max = add;
		if(add<0) add = 0;
	}
	printf("%d\n",max);
	}
	 return 0;
}

Double click to view unformatted code.


Back to problem 19