#include "stdio.h"
// Algorithm 1:
Int MaxSubsequencesum1 (Const Int A [], INT N)
{
Int Thissum, MaxSum, I, J, K;
MaxSum = 0;
For (i = 0; i For (j = i; j { THISSUM = 0; For (k = i; k <= j; k ) Thissum = a [k]; IF (thissum> maxsum) Maxsum = thissum; } Return MaxSum; } // Algorithm 2: Int MaxSubsequencesum2 (Const Int A [], INT N) { Int Thingsum, MaxSum, I, J; MaxSum = 0; For (i = 0; i { THISSUM = 0; For (j = i; j { Thissum = a [j]; IF (thissum> maxsum) Maxsum = thissum; } } Return MaxSum; } // Algorithm 4: Int MaxSubsequenceSum4 (Const Int A [], INT N) { Int Thissum, MaxSum, I; Thissum = maxSum = 0; For (i = 0; i { Thissum = a [i]; IF (thissum> maxsum) Maxsum = thissum; Else IF (Thissum <0) THISSUM = 0; } Return MaxSum; } //test int main () { INT A [] = {-2, 11, -4, 13, -5, -2}; INT size = sizeof (a) / sizeof (a [0]); Printf ("MaxSubsequencesum1:% D / N", MaxSubsequenceSum1 (A, SIZE)); Printf ("MaxSubsequencesum2:% D / N", MaxSubsequenceSum2 (a, size)); Printf ("MaxSubsequencesum4:% D / N", MaxSubSequenceSum4 (A, SIZE)); Return 0; }