Сократите эту программу, может, действия нахождения максимума одной процедурой сделать... program zelda;uses crt;const z=100;varu1,u2,u3:array[1..z]of integer;i,max1,max2,max3:integer;procedure ch1;var n,i,max1,max2,max3:integer;beginn:=7;for i:=1 to n dou1[i]:=random(100);for i:=1 to n dowriteln('Элементы массива: ',u1[i]);max1:=u1[i];max2:=u1[i];max3:=u1[i];for i:=1 to n doif u1[i]>max1 then beginmax1:=u1[i];end;for i:=1 to n doif (u1[i]>max2) and (u1[i]<>max1) then beginmax2:=u1[i];end;for i:=1 to n doif (u1[i]>max3) and (u1[i]<>max1) and (u1[i]<>max2) then beginmax3:=u1[i];end;writeln('max1: ',max1,' max2: ',max2,' max3: ',max3);end;procedure ch2;var n,i,ind,max1,max2,max3:integer;beginn:=13;for i:=1 to n dou2[i]:=random(100);for i:=1 to n dowriteln('Элементы массива: ',u2[i]);ind:=0;max1:=u2[i];max2:=u2[i];max3:=u2[i];for i:=1 to n doif u2[i]>max1 then beginmax1:=u2[i];end;for i:=1 to n doif (u2[i]>max2) and (u2[i]<>max1) then beginmax2:=u2[i];end;for i:=1 to n doif (u2[i]>max3) and (u2[i]<>max1) and (u2[i]<>max2) then beginmax3:=u2[i];end;writeln('max1: ',max1,' max2: ',max2,' max3: ',max3);end;procedure ch3;var n,i,max1,max2,max3:integer;beginn:=17;for i:=1 to n dou3[i]:=random(100);for i:=1 to n dowriteln('Элементы массива: ',u3[i]);max1:=u3[i];max2:=u3[i];max3:=u3[i];for i:=1 to n doif u3[i]>max1 then beginmax1:=u3[i];end;for i:=1 to n doif (u3[i]>max2) and (u3[i]<>max1) then beginmax2:=u3[i];end;for i:=1 to n doif (u3[i]>max3) and (u3[i]<>max1) and (u3[i]<>max2) then beginmax3:=u3[i];end;writeln('max1: ',max1,' max2: ',max2,' max3: ',max3);end;beginch1;ch2;ch3;end.
program zelda; uses crt; const z = 100; var u1,u2,u3: array[1..z] of integer; i,max1,max2,max3: integer;
procedure findMax(array: array of integer); var n, i, max1, max2, max3: integer; begin n := Length(array); for i := 0 to n - 1 do array[i] := random(100);
for i := 0 to n - 1 do writeln('Элементы массива: ', array[i]); max1 := array[0]; max2 := array[0]; max3 := array[0]; for i := 0 to n - 1 do begin if array[i] > max1 then max1 := array[i]; end; for i := 0 to n - 1 do begin if (array[i] > max2) and (array[i] <> max1) then max2 := array[i]; end; for i := 0 to n - 1 do begin if (array[i] > max3) and (array[i] <> max1) and (array[i] <> max2) then max3 := array[i]; end; writeln('max1: ', max1, ' max2: ', max2, ' max3: ', max3);
program zelda;
uses crt;
const
z = 100;
var
u1,u2,u3: array[1..z] of integer;
i,max1,max2,max3: integer;
procedure findMax(array: array of integer);
for i := 0 to n - 1 dovar
n, i, max1, max2, max3: integer;
begin
n := Length(array);
for i := 0 to n - 1 do
array[i] := random(100);
writeln('Элементы массива: ', array[i]);
max1 := array[0];
max2 := array[0];
max3 := array[0];
for i := 0 to n - 1 do
begin
if array[i] > max1 then
max1 := array[i];
end;
for i := 0 to n - 1 do
begin
if (array[i] > max2) and (array[i] <> max1) then
max2 := array[i];
end;
for i := 0 to n - 1 do
begin
if (array[i] > max3) and (array[i] <> max1) and (array[i] <> max2) then
max3 := array[i];
end;
writeln('max1: ', max1, ' max2: ', max2, ' max3: ', max3);
end;
begin
findMax(u1);
findMax(u2);
findMax(u3);
end.