Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,40 @@
Program GreatestSubsequentialSum(output);
var
a: array[1..11] of integer = (-1, -2, 3, 5, 6, -2, -1, 4, -4, 2, -1);
i, j: integer;
seqStart, seqEnd: integer;
maxSum, seqSum: integer;
begin
maxSum := 0;
seqStart := 0;
seqEnd := -1;
for i := low(a) to high(a) do
begin
seqSum := 0;
for j := i to high(a) do
begin
seqSum := seqSum + a[j];
if seqSum > maxSum then
begin
maxSum := seqSum;
seqStart := i;
seqEnd := j;
end;
end;
end;
writeln ('Sequence: ');
for i := low(a) to high(a) do
write (a[i]:3);
writeln;
writeln ('Subsequence with greatest sum: ');
for i := low(a) to seqStart - 1 do
write (' ':3);
for i := seqStart to seqEnd do
write (a[i]:3);
writeln;
writeln ('Sum:');
writeln (maxSum);
end.