[Algorithm entry classic] 8.1.3 divide and treat the maximum continuous and

int maxsum(int *A, int x, int y) / / return the largest array in the left than the right open interval [x, y) Continuous and
{
    Int i, m, v, L, R, max;
    If(y-x==1) return A[x]; //only one element, return directly
    m=x+(y-x)/2; //Divide the first step: divide into [x,m) and [m,y)
    Max=maxsum(A,x,m)>maxsum(A,m,y)?maxsum(A,x,m):maxsum(A,m,y);//Division and division second step: recursive solution
    v=0; L=A[m-1];//Division third step: merge (1)——the maximum continuous and left from the demarcation point to the left
    For(i=m-1;i>=x;i--) //L>?=v+=A[i];
    {
        v+=A[i];
        If(L<v)
        {
            L=v;
        }
    }
    v=0; R=A[m]; //Divide the third step: merge (2)——the maximum continuity from the demarcation point to the right and R
    For(i=m-1;i<y;i++) //R>?=v+=A[i];
    {
        v+=A[i];
        If(R<v)
        {
            R=v;
        }
    }
    Return max>(L+R)?max:(L+R);//max>?(L+R);//Compare the solution of the subproblem with L and R

}