Important Question: what does this code do in delphi ??

hi,
can someone please answer me the follwing question for the delphi code...im a VB.net expert but nill to delphi.
here it is
[b]1) What interesting property of the input array is the routine below attempting to discover?
2) Do you believe there are any logical errors in the routine below?
3) What problems, if any, would you anticipate if this routine was deployed in a commercial application?
4) Re-implement this routine in a form you would be happy to put your name to. Any language is acceptable for this task.
[/b]

here is the code

[code]
Procedure DiscoverSomethingInteresting(Input : Array Of Integer; Out x, y, z : Integer);
Var
i, j, k : Integer;
w : Integer;
Begin
z := -MaxInt;
For i := 1 To Length(Input) Do
Begin
For j := 0 To Length(Input) - i Do
Begin
w := 0;
For k := 0 To i - 1 Do
Begin
w := w + Input[j+k];
End;
If w > z Then
Begin
z := w;
x := j;
y := j+i-1;
End;
End;
End;
End;
[/code]


[b]Notes [/b]: The sample above is written in the Delphi language. The array is zero based and the Length function returns the number of elements in the array.
Thanks
AC

Comments

  • seems like, it's just counting the sum of the Input array in a complicated way... x always 0, y = length(input)-1, z = sum(input)...
    I don't know what the purpose of this code...
  • This code for determining the maximum value of array of integers
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories