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

Ответы

Ответ дал: shavrinatv
0

Ответ:

Так пойдёт?

Объяснение:

program Zeldaproj1;

{$mode objfpc}{$H+}

uses

{$IFDEF UNIX}{$IFDEF UseCThreads}

 cthreads,

 {$ENDIF}{$ENDIF}

 Classes

 { you can add units after this };

const z=100;

type mas=array[1..z] of integer;

var

 u1:mas;

 max1,max2,max3:integer;

procedure ch1(n:integer);

var i:integer;

begin

for i:=1 to n do

u1[i]:=random(100);

for i:=1 to n do

writeln('Элементы массива: ',u1[i]);

max1:=u1[i];max2:=u1[i];max3:=u1[i];

for i:=1 to n do

if u1[i]>max1 then begin

max1:=u1[i];

end;

for i:=1 to n do

if (u1[i]>max2) and (u1[i]<>max1) then begin

max2:=u1[i];

end;

writeln('max1: ',max1,' max2: ',max2,' max3: ',max3);

end;

begin

ch1(5);

readln;

ch1(7);

readln;

ch1(13);

readln;

end.

Вас заинтересует