Program fantscrin;
const n = 10;
Var a: array [1..n] of integer;
i,j,k:integer; s:real;
Begin
for i:=1 to n do
a[i]:=random(20)-10;
write(a[i], ' ');
for j:=1 to n-1 do
if (a[j]<a[j+1]) then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
end;
writeln('');
if (a[i] > 0) then s:=s+a[i];
s:=s/n;
writeln(s);
End.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Program fantscrin;
const n = 10;
Var a: array [1..n] of integer;
i,j,k:integer; s:real;
Begin
for i:=1 to n do
a[i]:=random(20)-10;
for i:=1 to n do
write(a[i], ' ');
for i:=1 to n do
for j:=1 to n-1 do
if (a[j]<a[j+1]) then
begin
k:=a[j];
a[j]:=a[j+1];
a[j+1]:=k;
end;
writeln('');
for i:=1 to n do
write(a[i], ' ');
for i:=1 to n do
if (a[i] > 0) then s:=s+a[i];
s:=s/n;
writeln('');
writeln(s);
End.