Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,32 @@
|
|||
/* REXX ***************************************************************
|
||||
* 10.08.2012 Walter Pachl Pascal algorithm -> Rexx -> NetRexx
|
||||
**********************************************************************/
|
||||
s=' -1 -2 3 5 6 -2 -1 4 -4 2 -1'
|
||||
maxSum = 0
|
||||
seqStart = 0
|
||||
seqEnd = -1
|
||||
Loop i = 1 To s.words()
|
||||
seqSum = 0
|
||||
Loop j = i to s.words()
|
||||
seqSum = seqSum + s.word(j)
|
||||
if seqSum > maxSum then Do
|
||||
maxSum = seqSum
|
||||
seqStart = i
|
||||
seqEnd = j
|
||||
end
|
||||
end
|
||||
end
|
||||
Say 'Sequence:'
|
||||
Say s
|
||||
Say 'Subsequence with greatest sum: '
|
||||
If seqend<seqstart Then
|
||||
Say 'empty'
|
||||
Else Do
|
||||
ol=' '.copies(seqStart-1)
|
||||
Loop i = seqStart to seqEnd
|
||||
w=s.word(i)
|
||||
ol=ol||w.right(3)
|
||||
End
|
||||
Say ol
|
||||
Say 'Sum:' maxSum
|
||||
End
|
||||
Loading…
Add table
Add a link
Reference in a new issue