guan96 2013-02-10 04:01:00
点我顶贴
收藏
删除
var
n,r,i:integer;
s:real;
a:array[1..2,1..1000] of integer;
procedure msort(y:integer);
var
k,j,t,u:integer;
begin
for k:= 1 to y-1 do
for j:= 1 to y-k do
begin
if a[1,j]>a[1,j+1] then
begin
t:=a[2,j];u:=a[1,j];
a[2,j]:=a[2,j+1];a[1,j]:=a[1,j+1];
a[2,j+1]:=t;a[1,j+1]:=u
end;
end;
end;
begin
readln(n);
for i:=1 to n do read(a[1,i]);
for i:=1 to n do a[2,i]:=i;
msort(n);
r:=0;
for i:= n-1 downto 1 do r:=r+a[1,i]*(n-i);
s:=r/n;
for i:=1 to n do write(a[2,i],' ');
writeln;
write(s:3:2);
end.