Title Description
Enter an array of integers with positive and negative numbers in the array. One or more consecutive integers in an array make up a sub-array. The maximum value for the and of all sub-arrays.
Enter a description
Input has multiple sets of data, each set of test data consists of two rows. The first behavior is an integer n (0<=n<=100000), and when n=0, the input ends.
The next line contains n integers (we guarantee that all integers belong to [ -1000,1000]).
Output description
For each test case, you need to output a single line of integers representing the maximum and the continuous sub-vectors.
Input sample
3-1 -3 -2
Output sample
-1
Test code
1#include <stdio.h>2 3 intMain ()4 {5 intN, I, cur, ans;6 inta[Ten];7scanf"%d", &n);8 for(i =0; I < n; i++)9 {Tenscanf"%d", &a[i]); One } AAns = cur = a[0]; - for(inti =1; I < n; i++) - { thecur = cur + a[i] > a[i]? Cur +A[i]: a[i]; -ans = ans > cur?ans:cur; - } -printf"%d\n", ans); + return 0; -}
One-dimensional array of contiguous sub-arrays of the largest and