[fpc-pascal] More Filter Madness
Nataraj S Narayan
natarajsn at gmail.com
Fri Oct 14 08:39:40 CEST 2011
Hi
Good candidate for recursive algorithm i think.
regards
Nataraj
On Fri, Oct 14, 2011 at 6:23 AM, Ko Hashiguchi
<ko.d.hashiguchi at gmail.com> wrote:
> Mine is more of a programming problem, rather than one native to Pascal, but
> here goes:
>
> I have a text file with many Double values. Looking more or less like below,
> but with hundreds of entries...
>
> 1.5
> 3.25
> 7.54
> 10.33
> 2.22
>
> The values listed are only for illustration. What I need to do is read the
> values in the first file and sum them up such that the output file starts
> with the first value, the second entry in the output file is the sum of the
> first AND second values, the third entry in the output file is the sum of
> the first, second and third values of the input file:
>
> 1.5
> 4.75 (1.5 + 3.25)
> 12.29 (1.5 + 3.25 + 7.54)
> 22.62 (1.5 + 3.25 + 7.54 + 10.33)
> 24.84 (1.5 + 3.25 + 7.54 + 10.33 + 2.22)
>
> The process of summing up continues to the end of the file.
>
> I figure this is a program loop problem, rather than a Pascal problem, but
> it's beyond me. I would greatly appreciate assistance.
>
> Thank you,
> Ko Hashiguchi
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list