Program Massive;
uses Crt;
const
M = 6;
var
D: array [1..M] of real;
i: integer;
sum: real;
indexMax: integer;
begin
ClrScr;
Randomize;
writeln ('Massive:');
indexMax := 1;
D[1] := 10;
D[1] := D[1] - Random(20);
writeln (D[1]);
for i:= 2 to M do
D[i] := 10.0;
D[i] := D[i] - Random(20);
writeln (D[i]);
if (D[i] > D[indexMax]) then
indexMax := i;
end;
writeln ('indexMax = ', indexMax);
sum := 0;
for i:= indexMax + 1 to M do
if (D[i] < 0) then sum := sum + D[i];
writeln ('Sum = ', sum);
readln
end.
Program Massive;
uses Crt;
const
M = 6;
var
D: array [1..M] of real;
i: integer;
sum: real;
indexMax: integer;
begin
ClrScr;
Randomize;
writeln ('Massive:');
indexMax := 1;
D[1] := 10;
D[1] := D[1] - Random(20);
writeln (D[1]);
for i:= 2 to M do
begin
D[i] := 10.0;
D[i] := D[i] - Random(20);
writeln (D[i]);
if (D[i] > D[indexMax]) then
begin
indexMax := i;
end;
end;
writeln ('indexMax = ', indexMax);
sum := 0;
for i:= indexMax + 1 to M do
if (D[i] < 0) then sum := sum + D[i];
writeln ('Sum = ', sum);
readln
end.