#include<stdlib.h> #include<string.h> #include<stdio.h> int main(){ int n,sum,max; scanf("%d",&n); while(n!=0){ int temp[10000] = {0}; for(int i=0;i<n;i++){ scanf("%d",&temp[i]); } max = temp[0]; for(int i=0; i<n; i++){ sum = 0; for(int j=i;j<n;j++){ sum += temp[j]; if(sum>max) max = sum; } } printf("%d\n",max); scanf("%d",&n); } return 0; } |
Double click to view unformatted code.