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
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.
here is the 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;
Notes : 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