#include<iostream> using namespace std; int main() { int n,max; while(cin>>n&&n!=0) { int a [n],temp; for(int i=0;i<n;i++) cin>>a[i]; max=-10000; for(int i=1;i<n;i++) { temp=a[i]; for(int j=i+1;j<n;j++) { temp=temp+a[j]; if(temp>max) max=temp; } } cout<<max<<endl; } } |
Double click to view unformatted code.