Dim sum()
Function xxf(A(), ByVal n)
ReDim sum(LBound(A) To UBound(A))
For i = LBound(A) To UBound(A)
For j = i To i + n - 1
If j > UBound(A) Then
k = j - UBound(A)
Else
k = j
End If
sum(i) = sum(i) + A(k)
Next
Print sum(i);
Next
Print
xxf = Max(sum())
End Function
Private Sub form_click()
Dim A(1 To 20)
n = Text1
Randomize
For i = 1 To 20
A(i) = Int(Rnd * 50 + 50)
Print A(i);
Next
Print
m = xxf(A(), n)
For i = m To m + n - 1
If i > UBound(sum) Then
k = i - UBound(sum)
Else
k = i
End If
s = s + 1
Print A(k);
If s <= n - 1 Then
Print "+";
End If
Next
Print "="; sum(m)
End Sub
Private Function Max(A())
Dim s
s = A(LBound(A))
For i = LBound(A) To UBound(A)
If A(i) >= s Then
s = A(i)
iMax = i
End If
Next
Max = iMax
End Function