//Видимо, это одна задача, так как "изменения" во второй не указаны //Pascal ABC.NET v3.1 сборка 1172
Const n=20;
Var ar:array[1..n] of integer; i:integer; begin randomize; writeln('First array:'); for i:=1 to n do begin ar[i]:=random(10)-3; write(ar[i]:4); if ar[i]>0 then ar[i]:=ar[i]*2 else ar[i]:=0; end; writeln; writeln('Final array:'); for i:=1 to n do write(ar[i]:4); end.
Program n1; Uses CRT; Const n=15; Var A: array[1..n] of integer; B: array[1..n] of integer; i,k,max: integer; begin randomize; clrscr; Writeln('ishodny massiv'); For i:=1 to n do begin a[i]:=random(100); a[i]:=a[i]-50; write(a[i]:4); end; writeln; writeln('polychenny massiv'); max:=0; For i:=1 to n do begin b[i]:=-a[i]; write(b[i]:4); If a[i]=b[i] then k:=k+1; If (b[i]>0)and(b[i]>max) then max:=b[i]; If (b[i]<0)and(-b[i]>max) then max:=-b[i]; end; writeln; Writeln('Kolychestvo neizmenyvshihsa elementov=',k,', samyi bolshoy po modyly element raven =',max); writeln end.
//Pascal ABC.NET v3.1 сборка 1172
Const
n=20;
Var
ar:array[1..n] of integer;
i:integer;
begin
randomize;
writeln('First array:');
for i:=1 to n do
begin
ar[i]:=random(10)-3;
write(ar[i]:4);
if ar[i]>0 then ar[i]:=ar[i]*2 else ar[i]:=0;
end;
writeln;
writeln('Final array:');
for i:=1 to n do
write(ar[i]:4);
end.
Пример работы программы:
First array: 2 -3 5 6 -3 -3 1 -2 -3 1 3 -3 4 -3 1 -1 6 6 2 3
Final array: 4 0 10 12 0 0 2 0 0 2 6 0 8 0 2 0 12 12 4 6
Program n1;
Uses CRT;
Const n=15;
Var A: array[1..n] of integer; B: array[1..n] of integer;
i,k,max: integer;
begin
randomize;
clrscr;
Writeln('ishodny massiv');
For i:=1 to n do
begin
a[i]:=random(100);
a[i]:=a[i]-50;
write(a[i]:4);
end;
writeln;
writeln('polychenny massiv');
max:=0;
For i:=1 to n do
begin
b[i]:=-a[i];
write(b[i]:4);
If a[i]=b[i] then k:=k+1;
If (b[i]>0)and(b[i]>max) then max:=b[i];
If (b[i]<0)and(-b[i]>max) then max:=-b[i];
end;
writeln;
Writeln('Kolychestvo neizmenyvshihsa elementov=',k,', samyi bolshoy po modyly element raven =',max);
writeln
end.