*process source attributes xref; ss: Proc Options(Main); /* REXX *************************************************************** * 26.08.2013 Walter Pachl translated from REXX version 3 **********************************************************************/ Dcl HBOUND builtin; Dcl SYSPRINT Print; Dcl (I,J,LB,MAXSUM,SEQEND,SEQSTART,SEQSUM) Bin Fixed(15); Dcl s(11) Bin Fixed(15) Init(-1,-2,3,5,6,-2,-1,4,-4,2,-1); maxSum = 0; seqStart = 0; seqEnd = -1; do i = 1 To hbound(s); seqSum = 0; Do j = i to hbound(s); seqSum = seqSum + s(j); if seqSum > maxSum then Do; maxSum = seqSum; seqStart = i; seqEnd = j; end; end; end; Put Edit('Sequence:')(Skip,a); Put Edit('')(Skip,a); Do i=1 To hbound(s); Put Edit(s(i))(f(3)); End; Put Edit('Subsequence with greatest sum:')(Skip,a); If seqend