1)var ar:array of integer; max,min,s,i,n,maxi,mini:integer; begin; randomize; max:=-1; min:=101; readln(n); setlength(ar,n+1); writeln('Array:'); for i:=1 to n do begin; ar[i]:=random(100); write(ar[i]:4); if max<ar[i] then begin; max:=ar[i]; maxi:=i; end; if min>ar[i] then begin; min:=ar[i]; mini:=i; end; s:=s+ar[i]; end; ar[maxi]:=s; ar[mini]:=s; writeln; writeln('Final array:'); for i:=1 to n do write(ar[i]:4); end. 2)var ar:array of integer; k,h,i,s:integer; f:real; begin; randomize; readln(h); setlength(ar,h+1); writeln('Array:'); for i:=1 to h do begin; ar[i]:=random(100)-50; write(ar[i]:4); if (ar[i]>0) and (ar[i] mod 2=0) then begin; inc(k); s:=s+ar[i]; end; end; f:=s/k; writeln; writeln('Result:',f); end.
Аношкина1696
03.02.2022
//PascalABC.NET 3.2 сборка 1318
var l, r, counter, i: integer;
function DifNum(a: integer): integer; var se: set of integer; i: integer; begin while a > 0 do begin if a mod 10 in se then begin DifNum := 0; exit; end else include(se, a mod 10); a := a div 10; end; DifNum := 1; end;
begin read(l, r); for i := l to r do counter += DifNum(i); writeln(counter); end.
//Альтернативное решение на Паскале
Var l,r:integer; begin read(l,r); writeln(range(l,r).where(x -> x.tostring.toarray.distinct.count=length(x.tostring)).Count); end.
max,min,s,i,n,maxi,mini:integer;
begin;
randomize;
max:=-1;
min:=101;
readln(n);
setlength(ar,n+1);
writeln('Array:');
for i:=1 to n do
begin;
ar[i]:=random(100);
write(ar[i]:4);
if max<ar[i] then
begin;
max:=ar[i];
maxi:=i;
end;
if min>ar[i] then
begin;
min:=ar[i];
mini:=i;
end;
s:=s+ar[i];
end;
ar[maxi]:=s;
ar[mini]:=s;
writeln;
writeln('Final array:');
for i:=1 to n do
write(ar[i]:4);
end.
2)var ar:array of integer;
k,h,i,s:integer;
f:real;
begin;
randomize;
readln(h);
setlength(ar,h+1);
writeln('Array:');
for i:=1 to h do
begin;
ar[i]:=random(100)-50;
write(ar[i]:4);
if (ar[i]>0) and (ar[i] mod 2=0) then
begin;
inc(k);
s:=s+ar[i];
end;
end;
f:=s/k;
writeln;
writeln('Result:',f);
end.