Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
*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<seqstart Then
|
||||
Put Edit('empty')(Skip,a);
|
||||
Else Do;
|
||||
/*ol=copies(' ',seqStart-1)*/
|
||||
lb=(seqStart-1)*3;
|
||||
Put Edit(' ')(Skip,a(lb));
|
||||
Do i = seqStart to seqEnd;
|
||||
Put Edit(s(i))(f(3));
|
||||
End;
|
||||
Put Edit('Sum:',maxSum)(Skip,a,f(5));
|
||||
End;
|
||||
End;
|
||||
Loading…
Add table
Add a link
Reference in a new issue