## Delphi and Kylix

Moderators: pritaeas
Number of posts: 19051

This Forum Only

Important Question: what does this code do in delphi ?? Posted by aamirwazir on 1 Jul 2009 at 8:22 AM
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
Re: Important Question: what does this code do in delphi ?? Posted by resoftw on 21 Feb 2010 at 12:20 AM
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...
Re: Important Question: what does this code do in delphi ?? Posted by eng_redaesm on 7 Mar 2010 at 10:35 PM
This code for determining the maximum value of array of integers

## Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic